Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript JQuery.click(函数()在IE中不起作用_Javascript_Jquery_Internet Explorer - Fatal编程技术网

Javascript JQuery.click(函数()在IE中不起作用

Javascript JQuery.click(函数()在IE中不起作用,javascript,jquery,internet-explorer,Javascript,Jquery,Internet Explorer,以下代码适用于除IE以外的所有浏览器。我正在使用IE 9,并且我已经包含了jquery库。为什么。单击(function()不起作用。函数中的代码从未运行过 newEntryRow.find('.dispmsg').click(function(){ alert("this code is not running"); showEntryById(1); }); 任何关于为什么会发生这种情况以及如何解决它的想法。谢谢 newEntryRow是li元素的克隆,但正如我上面所说的,

以下代码适用于除IE以外的所有浏览器。我正在使用IE 9,并且我已经包含了jquery库。为什么
。单击(function()
不起作用。函数中的代码从未运行过

newEntryRow.find('.dispmsg').click(function(){
    alert("this code is not running");
    showEntryById(1);
});
任何关于为什么会发生这种情况以及如何解决它的想法。谢谢


newEntryRow是li元素的克隆,但正如我上面所说的,它在所有其他浏览器中都可以工作。

验证“newEntryRow.find('.dispmsg')”是否返回元素。是否“.dispmsg”是一个标记?如果是,您可能需要调用event.preventDefault()。除此之外,您可以尝试使用.bind()相反。

showEntryById似乎表明您正在传递
id
值,但仅数字(
1
在您的情况下)不是
id
的有效值,请尝试使用字母或字母数字字母组合


还要确保
newEntryRow
是jQuery对象,尝试在控制台上输出它。

如果
newEntryRow.find('.dispmsg'),请在控制台上检查.length
大于0您可以对其进行分析,因此我们可以进行测试吗?假设newEntryRow不为null,这应该可以工作。您是否收到任何js错误?您可以使用JSFIDLE复制此错误吗?发布htm代码,从中获取
newEntryRow
数字ID在HTML5中有效,但代码永远不会达到该点,它不会执行alert@ewein:那么很可能是
newEntryRow
没有正确通过。@Alnitak:我知道,但问题没有标记为html5。正因为如此,尽管有人否决了。在任何现代浏览器上,html==html5。你的断言不再正确。我真的怀疑否决票是因为这个。这个答案只有makes sense up to the first statement=/如果元素是一个链接,那么您的单击事件将需要调用event.preventDefault()来停止链接元素的默认行为,以便代码运行。