-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
51 lines (35 loc) · 1.09 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
---
title: "DOMTokenList: value property"
short-title: value
slug: Web/API/DOMTokenList/value
page-type: web-api-instance-property
browser-compat: api.DOMTokenList.value
---
{{APIRef("DOM")}}
The **`value`** property of the {{domxref("DOMTokenList")}}
interface is a {{Glossary("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
{{htmlelement("span")}} element as a `DOMTokenList` using
{{domxref("Element.classList")}}, then write the value of the list to the
`<span>`'s {{domxref("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:
{{ EmbedLiveSample('Examples', '100%', 60) }}
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}