HTML DOMTokenList forEach() Method
- Previous Page entries()
- Next Page item()
- Go Back to the Previous Level HTML DOMTokenList
Definition and Usage
The forEach() method executes a callback function for each marker (token) in the DOMTokenList.
Example
Example 1
Get DOMTokenList from "demo":
let list = document.getElementById("demo").classList;
Example 2
Execute a function for each marker:
list.forEach( function(token, index) { text += index + " " + token; } );
Syntax
nodelist.forEach(function(currentValue, index, arr) thisValue)
Parameters
Parameters | Description |
---|---|
function() | Required. The function to be run for each marker. |
currentValue | Required. The current marked value. |
index | Optional. The current marked index. |
arr | Optional. The current marked DOMTokenList. |
thisValue |
Optional. Default undefined. The value passed to the function as its this value. |
Return Value
None.
Browser Support
domtokenlist.forEach() 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.forEach().
Related Pages
- Previous Page entries()
- Next Page item()
- Go Back to the Previous Level HTML DOMTokenList