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.
A string representing the serialized content of the list. Each item is separated by a space.
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:
<span class="a b c"></span>
Now the JavaScript:
const span = document.querySelector("span");
const classes = span.classList;
span.textContent = classes.value;
The output looks like this:
| Specification |
|---|
| DOM> # ref-for-dom-domtokenlist-value②> |
| 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 |
50Before Chrome 50, this property was part of the deprecated childDOMSettableTokenList interface. |
17 | 47 | 37Before Opera 37, this property was part of the deprecated childDOMSettableTokenList interface. |
10 | 50Before Chrome Android 50, this property was part of the deprecated childDOMSettableTokenList interface. |
47 | 37Before Opera Android 37, this property was part of the deprecated childDOMSettableTokenList interface. |
10 | 5.0Before Samsung Internet 5.0, this property was part of the deprecated childDOMSettableTokenList interface. |
50Before WebView Android 50, this property was part of the deprecated childDOMSettableTokenList interface. |
10 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenList/value