HTML DOMTokenList forEach() Method
- Previous Page entries()
- Next Page item()
- Back to Top HTML DOMTokenList
Definition and Usage
The forEach() method executes a callback function for each tag (token) in the DOMTokenList.
Example
Example 1
Get DOMTokenList from "demo":
let list = document.getElementById("demo").classList;
Example 2
Execute function for each tag:
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 tag. |
currentValue | Required. The current marked value. |
index | Optional. The current marked index. |
arr | Optional. The current marked DOMTokenList. |
thisValue |
Optional. Default undefined. As the value passed to the function of 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()
- Back to Top HTML DOMTokenList