Table of contents
Introduction
- A DOMTokenList is a set of space-separated tokens.
- A DOMTokenList can be accessed by index (starts at 0).
- The length Property returns the number of tokens in a DOMTokenList.
Note: The classList Property of an HTML element represents a DOMTokenList
- In simpler terms it will be a list of CSS classes which are divided by space.
DomTokenList Properties & Methods
- add(): The add() method adds one (or more) tokens to a DOMTokenList. Here the tokens are CSS classes
- contains(): The contains() method returns true if a DOMTokenList contains a class, otherwise false.
- remove(): The remove() method removes one (or more) tokens from a DOMTokenList.
- length: The length property returns the number of tokens in a DOMTokenList. The length property is read-only.
- values() : The values() method returns an Iterator with the values from a DOMTokenList.