for of 循环 querySelectorAll [英] for of loop querySelectorAll
本文介绍了for of 循环 querySelectorAll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Mozilla 声明for of 循环将正确地遍历 NodeList 对象".(来源:https://developer.mozilla.org/en-US/docs/Web/API/NodeList) 但是,这在 Chrome 43 中不起作用.这是不正确的文档还是浏览器错误?
Mozilla states that "for of loops will loop over NodeList objects correctly". (source: https://developer.mozilla.org/en-US/docs/Web/API/NodeList) However, this doesn't work in Chrome 43. Is this incorrect documentation or a browser bug?
在带有复选框的页面上使用的复制示例代码:
The copied example code used on a page with checkboxes:
var list = document.querySelectorAll( 'input[type=checkbox]' );
for (var item of list) {
item.checked = true;
}
推荐答案
NodeList.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator]
和 for of 循环.
And for of loops.
这篇关于for of 循环 querySelectorAll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文