jQuery点击事件未绑定到Firefox中的元素,适用于Chrome

时间:2015-05-03 23:20:18

标签: jquery firefox javascript-events

我有以下HTML:

 2.2.0 :066 > obj.methods(false)
 => [:label=, :label, :description=, :description, :thumbnail=, :thumbnail, :attribution=, :attribution, :license=, :license, :logo=, :logo, :see_also=, :seeAlso=, :see_also, :seeAlso, :related=, :related, :within=, :within, :metadata=, :metadata, :sequences=, :sequences, :structures=, :structures, :viewing_hint=, :viewingHint=, :viewing_hint, :viewingHint, :viewing_direction=, :viewingDirection=, :viewing_direction, :viewingDirection, :service=, :service] 

以及以下jQuery / JS:

<a id="ajaxToggleHotkeys"  title="Toggle Hotkey Info" href="#" style="display: inline;"><i class="fa fa-keyboard-o"></i></a>

是的,JS代码在

$('#ajaxToggleHotkeys').on('click', function(event) {
    toggleHotkeysDisplay ();
});

块。

这在Chrome中运行得非常好,但在Firefox中,事件并不会激发。如果我使用Firefox&#34; Inspect Element&#34;工具,我没有看到任何与此元素绑定的事件。

因此,由于某种原因,事件未绑定到#ajaxToggleHotkeys元素。我现在已经对着这个人敲了几个小时,现在完全失去了。

有人有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我在Firefox上运行代码没问题。

&#13;
&#13;
$('#ajaxToggleHotkeys').on('click', function(event) {
    toggleHotkeysDisplay ();
});

function toggleHotkeysDisplay(){
$(document).ready(function(){
alert("I'm here")
});
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<a id="ajaxToggleHotkeys"  title="Toggle Hotkey Info" href="#" style="display: inline;"><i class="fa fa-keyboard-o"></i> TEST</a>
&#13;
&#13;
&#13;

尝试以安全模式启动Firefox并检查错误是否仍然存在。

  

您可以通过两种方式在安全模式下启动Firefox

Hold the SHIFT key while double clicking the Firefox icon in your desktop
Press the Windows key + R (open the Run command) and type firefox -safe-mode
相关问题