JavaScripture
Contribute via GitHub Feedback

DOMTokenList : Object

An object containing a list of strings. Used in Element.classList and HTMLIFrameElement.sandbox.

Instance Indexers

this[index : Number] : String

Retrieves the token at index. You can also use the item() method.

Example:

Run

Results:

 

Instance Properties

length : Number  

The number of tokens in this.

Example:

Run

Results:

 

value : String

A string value of the token list. See also className.

Example:

Run

Results:

 

Instance Methods

add(token : String) : undefined

Adds token to this.

Example:

Run

Results:

 

contains(token : String) : Boolean

Returns true if token is in this and false otherwise.

Example:

Run

Results:

 

item(index : Number) : String
remove(token : String) : undefined

Removes token from this.

Example:

Run

Results:

 

replace(oldToken : String, newToken : String) : Boolean

If oldToken is present in this, removes oldToken, adds newToken, and returns true. Otherwise, makes no changes and returns false.

Example:

Run

Results:

 

toggle(token : String, [value : Boolean]) : Boolean

If value is not specified, removes token from the list if was in this or adds token to the list if it was not in this. If value is true, token is added to this if not already there. If value is false, token is removed from this.

Example:

Run

Results: