DOMTokenList: value プロパティ
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.
value
は DOMTokenList
インターフェイスの文字列化プロパティで、リストの値を文字列としてシリアライズして返したり、リストを空にしたり渡された値に設定したりするためのものです。
値
リストの内容をシリアライズした文字列です。 それぞれの項目は空白で区切られます。
例
次の例では、 <span>
要素に設定されたクラスのリストを Element.classList
を使用して DOMTokenList
として取得し、リストの値を <span>
の Node.textContent
の中に書き込みます。
最初に HTML です。
html
<span class="a b c"></span>
そして JavaScript です。
js
const span = document.querySelector("span");
const classes = span.classList;
span.textContent = classes.value;
出力結果は以下のようになります。
仕様書
Specification |
---|
DOM # ref-for-dom-domtokenlist-value② |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
value |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.