简体   繁体   English

jQuery .click(function()在IE中不起作用

[英]JQuery .click(function() not working in IE

The following code works in all browsers but IE. 以下代码可用于除IE之外的所有浏览器。 I am using IE 9 and I have included the jquery library. 我正在使用IE 9,并且包含了jquery库。 Why is the .click(function() not working. The code inside the function is never ran. .click(function()为什么不起作用,函数内的代码永远不会运行。

newEntryRow.find('.dispmsg').click(function(){
    alert("this code is not running");
    showEntryById(1);
});

Any ideas why this might be happening and any ideas how to fix it. 为什么会发生这种情况的任何想法,以及如何解决它的任何想法。 Thanks. 谢谢。

newEntryRow is a clone of li element, but like I said above it works in all other browsers. newEntryRow是li元素的一个克隆,但是就像我上面说的那样,它在所有其他浏览器中都可以使用。

Verify that "newEntryRow.find('.dispmsg')" is returning an element. 验证“ newEntryRow.find('。dispmsg')”是否正在返回元素。 Is ".dispmsg" an a tag? “ .dispmsg”是标签吗? iF it is you may need to call event.preventDefault(). 如果是,则可能需要调用event.preventDefault()。 Other than that you can try using .bind() instead. 除此之外,您可以尝试使用.bind()代替。

The showEntryById seems to suggest that you are passing id value, however digit alone ( 1 in your case) isn't valid value for id , try using alpha or combination of alphanumeric letters. showEntryById似乎建议您传递id值,但是仅数字(在您的情况下为1 )不是id有效值,请尝试使用字母或字母数字字母的组合。

Also make sure that newEntryRow is a jQuery object, try outputting it on console. 还要确保newEntryRow是一个jQuery对象,尝试在控制台newEntryRow其输出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM