HTML DOM NodeList values() Method

Definition and Usage

The values() method returns an iterator containing values from the NodeList.

Example

Example 1

List the child nodes of the document:

const list = document.body.childNodes;
for (let x of list.values()) {
  text += x;
}

Try it yourself

Example 2

List the names of document child nodes:

const list = document.body.childNodes;
for (let x of list.values()) {
  text += x.nodeName;
}

Try it yourself

Example 3

List the types of document child nodes:

const list = document.body.childNodes;
for (let x of list.values()) {
  text += x.nodeType;
}

Try it yourself

Syntax

nodelist.values()

Parameters

No parameters.

Return Value

Type Description
Object Iterator object containing the values in the list.

Browser Support

nodelist.values() is a DOM Level 4 (2015) feature.

All modern browsers support it:

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Supported Supported Supported Supported Supported

Internet Explorer 11 (or earlier versions) does not support nodelist.values().

Related Pages

length Property

entries() Method

forEach() Method

item() Method

keys() Method

NodeList Object

childNodes() Method

querySelectorAll() Method

getElementsByName() Method