[英]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. 我试图用.each函数替换for循环来隐藏一系列元素,该循环在IE9中不起作用,而代码在FF中有效,而在IE 9中则无效。
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循环形式
for (var i = 0; i < myArray.length; i++)
{
$("#" + myArray[i].attributes["id"].value).hide();
}
Why are you using getElementsByName
? 为什么使用getElementsByName
? Just use jQuery to get the elements, then just .hide
them. 只需使用jQuery获取元素,然后将其.hide
即可。
$('[name="hide[]"]').hide();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.