ert3
ert3

Reputation: 114

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();
  }

Upvotes: 0

Views: 1063

Answers (1)

gen_Eric
gen_Eric

Reputation: 227270

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

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

Upvotes: 9

Related Questions