nodeValue
特性为
节点
interface returns or sets the value of the current node.
str = node.nodeValue; node.nodeValue = str;
str
is a string containing the value of the current node, if any. For the document itself,
nodeValue
返回
null
. For text, comment, and CDATA nodes,
nodeValue
returns the content of the node. For attribute nodes, the value of the attribute is returned.
The following table shows the return values for different elements:
| 节点 | Value of nodeValue |
|---|---|
CDATASection
|
Content of the CDATA section |
注释
|
Content of the comment |
Document
|
null
|
DocumentFragment
|
null
|
DocumentType
|
null
|
元素
|
null
|
NamedNodeMap
|
null
|
EntityReference
|
null
|
Notation
|
null
|
ProcessingInstruction
|
Entire content excluding the target |
文本
|
Content of the text node |
当
nodeValue
is defined to be
null
, setting it has no effect.
| 规范 | 状态 | 注释 |
|---|---|---|
|
DOM
The definition of 'Node: nodeValue' in that specification. |
实时标准 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
nodeValue
|
Chrome Yes | Edge 12 | Firefox Yes | IE ? | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android Yes | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
完整支持
兼容性未知
节点
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
DOMTokenList
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