Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. DOMTokenList
  4. values()

DOMTokenList: values() method

Baseline Widely available

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

Thevalues() method of theDOMTokenList interfacereturns aniteratorallowing the caller to go through all values contained in theDOMTokenList.The individual values are strings.

Syntax

js
values()

Parameters

None.

Return value

Returns aniterator.

Examples

In the following example we retrieve the list of classes set on a<span> element as aDOMTokenList usingElement.classList. We when retrieve an iterator containing the valuesusingvalues(), then iterate through those values using afor...of loop,writing each one to the<span>'sNode.textContent.

First, the HTML:

html
<span></span>

Now the #"span");const classes = span.classList;const iterator = classes.values();for (const value of iterator) { span.textContent += `(${value}) `;}

The output looks like this:

Specifications

This feature does not appear to be defined in any specification.

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp