简体   繁体   中英

JQuery acting odd in IE when I'm NOT in compatibility mode

this is odd and I'm not sure why it is happening. I have this piece of code:

for(var x=0; x<8; x++){
  var y = $('#divID'+x).html();
  console.log(y);
}

When I am IN IE9 compatibility mode it works just fine. However, when I turn OFF IE9 compatibility mode it doesn't work, nothing appears in the console or on my page. Now here is the odd thing, When I using this snippet of code instead, it works just fine.

for(var x=0; x<8; x++){
  var y = document.getElementById('divID'+x).innerHTML;
  console.log(y);
}

Is there something I am missing? Please help and thank you in advance.

IE doesn't support the console object till IE11...bummer, huh? It will break your js. Debug in Chrome...just use the IE browser as a final check after your js checks out in Chrome...just be sure to remove or comment your console.log/debug lines.

You need to consider these points:

  1. Firstly check if some of your code is incorrect in your $(document).ready() .
  2. If that all looks fine reload your page and hit F12 click the script tab then click start debugging and it will reload the page and halt it with a break point at your error in JavaScript..

jQuery does work in IE9 RC.

However, if you are doing something that IE doesnot support near the top of your $(document).ready() it could be preventing the rest of the page from loading.

Also http://code.jquery.com/jquery-1.5.1rc1.js , this should help you.

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