Reputation: 114
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
Reputation: 227270
Why are you using getElementsByName
? Just use jQuery to get the elements, then just .hide
them.
$('[name="hide[]"]').hide();
Upvotes: 9