HTML DOM NodeList keys()
❮ The NodeList ObjectExamples
List the keys of the document's child nodes:
const list = document.body.childNodes;
for (let x of list.keys()) {
text += x;
}
Try it Yourself »
List the documents's child nodes:
const list = document.body.childNodes;
for (let x of list.values()) {
text += x;
}
Try it Yourself »
Definition and Usage
The keys()
method returns an Iterator with the keys from a
NodeList.
See Also:
Syntax
nodelist.keys()
Parameters
NONE |
Return Value
Type | Description |
Object | An Iterator object with the keys from the list. |
Browser Support
nodelist.keys()
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.keys()
is not supported in Internet Explorer 11 (or earlier).
❮ The NodeList Object