HTML DOM NodeList keys() Method
- Previous Page item()
- Next Page length
- Go to the Previous Level HTML DOM NodeList
Definition and Usage
The keys() method returns an Iterator containing the keys of the NodeList.
Example
Example 1
List the keys of the child nodes of the document:
const list = document.body.childNodes; for (let x of list.keys()) { text += x;
Example 2
List the child nodes of the document:
const list = document.body.childNodes; for (let x of list.values()) { text += x;
Syntax
nodelist.keys()
Parameters
No parameters.
Return Value
Type | Description |
---|---|
Object | Iterator object containing the keys of the list. |
Browser Support
nodelist.keys() is a DOM Level 4 (2015) feature.
All modern browsers support it:
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
Internet Explorer 11 (or earlier versions) does not support nodelist.keys().
Related Pages
- Previous Page item()
- Next Page length
- Go to the Previous Level HTML DOM NodeList