HTML DOMTokenList forEach()
❮ The DOMTokenList ObjectExamples
Get a DOMTokenList from "demo":
let list = document.getElementById("demo").classList;
Try it Yourself »
Execute a function for each token:
list.forEach(
function(token, index) {
text += index + " " + token;
}
);
Try it Yourself »
Description
The forEach()
method executes a callback function for each token in a
DOMTokenList.
See Also:
Syntax
nodelist.forEach(function(currentValue, index, arr), thisValue)
Parameters
function() | Required. A function to run for each token. |
currentValue | Required. The value of the current token. |
index | Optional. The index of the current token. |
arr | Optional. The DOMTokenList of the current token. |
thisValue | Optional. Default undefined .A 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 in all modern browsers:
Chrome | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes |
domtokenlist.forEach()
is not supported in Internet Explorer 11 (or earlier).
❮ The DOMTokenList Object
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.