DOMTokenList: value property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2018.

The value property of the DOMTokenList interface is a stringifier that returns the value of the list serialized as a string, or clears and sets the list to the given value.

Value

A string representing the serialized content of the list. Each item is separated by a space.

Examples

In the following example we retrieve the list of classes set on a <span> element as a DOMTokenList using Element.classList, then write the value of the list to the <span>'s Node.textContent.

First, the HTML:

html
<span class="a b c"></span>

Now the JavaScript:

js
const span = document.querySelector("span");
const classes = span.classList;
span.textContent = classes.value;

The output looks like this:

Specifications

Specification
DOM
# ref-for-dom-domtokenlist-value②

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
value
Chrome – Full support
Chrome 50 (Release date: 2016-04-13)
footnote
footnote Before Chrome 50, this property was part of the deprecated child DOMSettableTokenList interface.
Edge – Full support
Edge 17 (Release date: 2018-04-30)
footnote Full support
Firefox – Full support
Firefox 47 (Release date: 2016-06-07)
footnote Full support
Opera – Full support
Opera 37 (Release date: 2016-05-04)
footnote
footnote Before Opera 37, this property was part of the deprecated child DOMSettableTokenList interface.
Safari – Full support
Safari 10 (Release date: 2016-09-20)
footnote Full support
Chrome Android – Full support
Chrome Android 50 (Release date: 2016-04-13)
footnote
footnote Before Chrome Android 50, this property was part of the deprecated child DOMSettableTokenList interface.
Firefox for Android – Full support
Firefox for Android 47 (Release date: 2016-06-07)
footnote Full support
Opera Android – Full support
Opera Android 37 (Release date: 2016-06-16)
footnote
footnote Before Opera Android 37, this property was part of the deprecated child DOMSettableTokenList interface.
Safari on iOS – Full support
Safari on iOS 10 (Release date: 2016-09-13)
footnote Full support
Samsung Internet – Full support
Samsung Internet 5 (Release date: 2016-12-15)
footnote
footnote Before Samsung Internet 5.0, this property was part of the deprecated child DOMSettableTokenList interface.
WebView Android – Full support
WebView Android 50 (Release date: 2016-04-13)
footnote
footnote Before WebView Android 50, this property was part of the deprecated child DOMSettableTokenList interface.
WebView on iOS – Full support
WebView on iOS 10 (Release date: 2016-09-13)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.