简体   繁体   English

jQuery 点击事件不起作用 IE7 和 IE8

[英]jQuery click event not working IE7 and IE8

The following code in IE7 or IE8 doesn't work. IE7 或 IE8 中的以下代码不起作用。 Is this a bug?这是一个错误吗? It works fine in IE6 (Incredible!)它在 IE6 中运行良好(难以置信!)

http://jsfiddle.net/zgSmT/ http://jsfiddle.net/zgSmT/

Try using the live event, or binding the event after document load:尝试使用live事件,或在document加载后绑定事件:

$('#clickme').live('click', function(){
    alert('hey');
});

Also, you're still loading scripts.js , which doesn't exist, in your fiddle example - that might also cause a problem.此外,在小提琴示例中,您仍在加载不存在的scripts.js ——这也可能导致问题。

You might try你可以试试

$().ready(function ()
{
    $('#clickme').live('click', function(){
        alert('hey');
    });
}

To ensure everything is loaded.以确保所有内容都已加载。

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

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