HTML DOMTokenList length Property

Definition and Usage

The length property returns the number of tags (tokens) in DOMTokenList.

The length property is read-only.

Example

Example 1

Get DOMTokenList from "demo":

let list = document.getElementById("demo").classList;

Try it Yourself

Example 2

Get the number of tags (classes) in the list:

let number = list.length;

Try it Yourself

Syntax

domtokenlist.length

Return Value

Type Description
Number The number of tags in DOMTokenList.

Browser Support

All browsers support domtokenlist.length:

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Support 10-11 Support Support Support Support

Related Pages

item() Method

add() Method

remove() Method

toggle() Method

forEach() Method

entries() Method

keys() Method

values() Method

DOMTokenList Object