onclick事件在Firefox上失败 [英] onclick event fails on firefox
本文介绍了onclick事件在Firefox上失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我点击搜索框中的图标时,它会提交搜索。在Chrome上完美工作...只测试了Firefox作为其他浏览器但失败(不会做任何事情)我做错了什么?
When I click on the icon in the search box it submits the search. Works perfectly on Chrome... only tested firefox as other browser but fails (wont do anything) have I done something wrong?
<form class="custom-search-form navbar-search" action="/search" method="GET" >
<input name="keyword" class="autocomplete span4" placeholder="Search for an Attraction...">
<a href="javascript:(.submit());" onclick="submit()" class="icon-search"></a>
</form>
问题在于href。
推荐答案
试试这个答案。
使用< a>提交表单标签
Firefox正在抱怨'submit'没有定义。
Firefox is complaining that 'submit' is not defined.
试试这个小提琴: http://jsfiddle.net/mspaly/eje6H/1/
<form id="my_form" class="custom-search-form navbar-search" action="/search" method="GET" >
<input name="keyword" class="autocomplete span4" placeholder="Search for an Attraction...">
<a href="javascript:{}" onclick="document.getElementById('my_form').submit()" class="icon-search">search</a>
</form>
还要注意,您必须为表单元素添加ID
Note also that you would have to add an ID to your form element
这篇关于onclick事件在Firefox上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文