Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. DOMTokenList
  4. length

DOMTokenList: length property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

The read-onlylength property of theDOMTokenList interface is aninteger representing the numberof objects stored in the object.

Value

A positive integer, or0 if the list is empty.

Examples

In the following example we retrieve the list of classes set on a<span> element as aDOMTokenList usingElement.classList, then write the length of the list to the<span>'sNode.textContent.

First, the HTML:

html
<span></span>

Now the #"span");const classes = span.classList;const length = classes.length;span.textContent = `classList length = ${length}`;

The output looks like this:

Specifications

Specification
DOM
# ref-for-dom-domtokenlist-length①

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp