简体   繁体   中英

document.body not working in IE

I am trying to create a simple on click function, but IE isn't cooperating. This works when I use it in chrome. When I call this function in IE, the function doesn't execute. IE version: 11

<script language="JavaScript">
AJS.$(document).ready(function($) {

AJS.$(document.body).on("click", "#Test-button", function() {

    });

});
</script>

Thanks in advance.

document.body not work in IE, remove the body and only use document

Just change your code to :

<script language="JavaScript">
AJS.$(document).ready(function($) {

AJS.$(document).on("click", "#Test-button", function() {

});

});
</script>

https://jsfiddle.net/tLa4mxgp/

Making a wild assumtion here. AJS.$ is your jQuery

AJS.$(document).find('body').on("click", "#Test-button", function() {

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