This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

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