简体   繁体   中英

jQuery click event not working IE7 and IE8

The following code in IE7 or IE8 doesn't work. Is this a bug? It works fine in IE6 (Incredible!)

http://jsfiddle.net/zgSmT/

Try using the live event, or binding the event after document load:

$('#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.

You might try

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

To ensure everything is loaded.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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