HTML DOM NodeList entries() Method
- Previous page entries()
- Next page forEach()
- Go back to the previous level HTML DOM NodeList
Definition and Usage
The entry() method returns an iterator with key/value pairs from the NodeList.
Example
Example 1
List the entries of the document child nodes:
const list = document.body.childNodes; for (let x of list.entries()) { text += x[0] + " " + x[1]; }
Example 2
List the names of the document child nodes:
const list = document.body.childNodes; for (let x of list.entries()) { text += x[0] + " " + x[1].nodeName; }
Example 3
List the values of the document child nodes:
const list = document.body.childNodes; for (let x of list.entries()) { text += x[0] + " " + x[1].nodeValue; }
Example 4
Get the keys of the child nodes of the <body> element:
const list = document.body.childNodes; for (let x of list.keys()) { ... code ... }
Example 5
Get the values of the child nodes of the <body> element:
const list = document.body.childNodes; for (let x of list.values()) { ... code ... }
Syntax
nodelist.entries()
Parameters
No parameters.
Return Value
Type | Description |
---|---|
Object | Iterator object with key/value pairs in the list. |
Browser Support
nodelist.entries() 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.entries().
Related Pages
- Previous page entries()
- Next page forEach()
- Go back to the previous level HTML DOM NodeList