简体   繁体   中英

JQuery .click(function() not working in IE

The following code works in all browsers but IE. I am using IE 9 and I have included the jquery library. Why is the .click(function() not working. The code inside the function is never ran.

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.

Verify that "newEntryRow.find('.dispmsg')" is returning an element. Is ".dispmsg" an a tag? iF it is you may need to call event.preventDefault(). Other than that you can try using .bind() instead.

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.

Also make sure that newEntryRow is a jQuery object, try outputting it on console.

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