Get the DOMTokenList from "demo":
let list = document.getElementById("demo").classList;
Try it Yourself »
Get the number of tokens (classes) in the list:
let number = list.length;
Try it Yourself »
The length
property returns the number of tokens in a DOMTokenList.
The length
property is read-only.
domtokenlist.length
Type | Description |
Number | The number of tokens in the The DOMTokenList. |
domtokenlist.length
is supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | 10-11 | Yes | Yes | Yes | Yes |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!