简体   繁体   中英

jquery .each() not working in IE 9

im trying to hide a series of elements with the .each function replacing a for loop which wasn't working in IE9, while the code works in FF it wont work in IE.

var myArray=document.getElementsByName("hide[]");
$.each(myArray, function(i, id) {$("#" + myArray[i].attributes["id"].value).hide();});

not entirely sure whats failing

in for loop form

for (var i = 0; i < myArray.length; i++)
  {
  $("#" + myArray[i].attributes["id"].value).hide();
  }

Why are you using getElementsByName ? Just use jQuery to get the elements, then just .hide them.

$('[name="hide[]"]').hide();

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