HTML DOMTokenList keys() Method
- Previous page item()
- Next page length
- Go back to the previous level HTML DOMTokenList
Definition and Usage
The keys() method returns an iterator (Iterator) with keys from the DOMTokenList.
Example
Example 1
Get DOMTokenList from "demo":
let list = document.getElementById("demo").classList;
Example 2
List the keys in the list:
const list = document.body.childNodes; for (let x of list.keys()) { text += x; }
Example 3
List the values in the list:
const list = document.body.childNodes; for (let x of list.values()) { text += x; }
Syntax
domtokenlist.keys()
Parameters
No parameters.
Return Value
Type | Description |
---|---|
Object | Iterator object containing the keys of the list. |
Browser Support
domtokenlist.keys() 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.keys().
Related Pages
- Previous page item()
- Next page length
- Go back to the previous level HTML DOMTokenList