The querySelectorAll()
method run on document
returns a list of DOM elements that satisfy the selectors query.
在document
运行的querySelectorAll()
方法返回满足选择器查询的DOM元素列表。
It returns a list of elements, which is not an array but a NodeList
object.
它返回元素列表,该列表不是数组而是NodeList
对象。
The easiest way to loop over the results is to use the for..of
loop:
遍历结果的最简单方法是使用for..of
循环:
for (const item of document.querySelectorAll('.buttons')) {
//...do something
}