List the document's child nodes:
const list = document.body.childNodes;
for (let x of list.values()) {
text += x;
}
Try it Yourself »
List the names of the document's child nodes:
const list = document.body.childNodes;
for (let x of list.values()) {
text += x.nodeName;
}
Try it Yourself »
List the types of the document's child nodes:
const list = document.body.childNodes;
for (let x of list.values()) {
text += x.nodeType;
}
Try it Yourself »
The values()
method returns an Iterator with the values from a NodeList.
nodelist.values()
NONE |
Type | Description |
Object | An Iterator object with the values from the list. |
nodelist.values()
is a DOM Level 4 (2015) feature.
It is supported in all modern browsers:
Chrome | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes |
nodelist.values()
is not supported in Internet Explorer 11 (or earlier).
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!