add
Summary
Adds one or more tokens to a DOMTokenList.
Method of dom/DOMTokenListdom/DOMTokenList
Syntax
var result = element.add(token);
Parameters
token
- Data-type
- String
The token to add to the DOMTokenList.
Return Value
Returns an object of type BooleanBoolean
Examples
//adds an item to an element's classList (a DOMTokenList)
function elAddItem(elid,itemadd) {
var classes = document.getElementById(elid).classList;
classes.add(itemadd);
}
Related specifications
- W3C DOM4
- Candidate Recommendation