值
特性为
DOMTokenList
interface is a stringifier that returns the value of the list as a
DOMString
, or clears and sets the list to the given value.
tokenList.value;
In the following example we retrieve the list of classes set on a
<span>
element as a
DOMTokenList
使用
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:
let span = document.querySelector("span");
let classes = span.classList;
span.textContent = classes.value;
输出看起来像这样:
| 规范 | 状态 | 注释 |
|---|---|---|
|
DOM
The definition of 'value' in that specification. |
实时标准 | 初始定义 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
value
|
Chrome
50
注意事项
|
Edge ≤18 | Firefox Yes | IE 不支持 No |
Opera
37
注意事项
|
Safari 10 |
WebView Android
50
注意事项
|
Chrome Android
50
注意事项
|
Firefox Android Yes |
Opera Android
37
注意事项
|
Safari iOS 10 |
Samsung Internet Android
5.0
注意事项
|
完整支持
不支持
见实现注意事项。
DOMTokenList
AbortController
AbortSignal
AbstractRange
Attr
ByteString
CDATASection
CSSPrimitiveValue
CSSValue
CSSValueList
CharacterData
ChildNode
注释
CustomEvent
DOMConfiguration
DOMError
DOMErrorHandler
DOMException
DOMImplementation
DOMImplementationList
DOMImplementationRegistry
DOMImplementationSource
DOMLocator
DOMObject
DOMParser
DOMPoint
DOMPointInit
DOMPointReadOnly
DOMRect
DOMString
DOMTimeStamp
DOMUserData
Document
DocumentFragment
DocumentType
元素
ElementTraversal
Entity
EntityReference
事件
EventTarget
HTMLCollection
MutationObserver
节点
NodeFilter
NodeIterator
NodeList
NonDocumentTypeChildNode
ProcessingInstruction
PromiseResolver
范围
StaticRange
文本
TextDecoder
TextEncoder
TimeRanges
TreeWalker
TypeInfo
USVString
UserDataHandler
XMLDocument