length
Summary
Returns the number of tokens in a DOMTokenList.
Property of dom/DOMTokenListdom/DOMTokenList
Syntax
Note: This property is read-only.
var result = element.length;
Return Value
Returns an object of type NumberNumber
Examples
//returns the number of classes in an element's classList (a DOMTokenList)
function elNumClasses(elid) {
var classes = document.getElementById(elid).classList;
return classes.length;
}
Related specifications
- W3C DOM4
- Candidate Recommendation