HTML DOMTokenList values() Method

Definition and Usage

The values() method returns an iterator (Iterator) with values from the DOMTokenList.

Example

Example 1

Get DOMTokenList from "demo":

let list = document.getElementById("demo").classList;

Try it yourself

Example 2

List the keys of the list:

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

Try it yourself

Example 3

List the values in the list:

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

Try it yourself

Syntax

domtokenlist.values()

Parameters

No parameters.

Return Value

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

Browser Support

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

It is supported by all browsers:

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support

Internet Explorer 11 (and earlier versions) does not support domtokenlist.values().

Related Pages

length Property

item() Method

add() Method

remove() Method

toggle() Method

replace() Method

forEach() Method

entries() Method

keys() Method

DOMTokenList Object