过时
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
重要
: For compatibility reasons, this property has been replaced by the
Node.getRootNode()
方法。
Node.rootNode
只读特性返回
节点
object representing the topmost node in the tree, or the current node if it's the topmost node in the tree. This is found by walking backward along
Node.parentNode
until the top is reached.
rootNode = node.rootNode;
A
节点
object representing the topmost node in the tree.
Running the following line in supporting browsers should return a reference to the HTML/document node:
console.log(document.body.rootNode);
Gecko-based browsers insert text nodes into a document to represent whitespace in the source markup. Therefore a node obtained, for example, using
Node.firstChild
or
Node.previousSibling
may refer to a whitespace text node rather than the actual element the author intended to get.
见 Whitespace in the DOM and W3C DOM 3 FAQ: Why are some Text nodes empty? 了解更多信息。
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
rootNode
弃用
非标
|
Chrome No | Edge No | Firefox No | IE ? | Opera No | Safari ? | WebView Android No | Chrome Android No | Firefox Android No | Opera Android No | Safari iOS ? | Samsung Internet Android No |
不支持
兼容性未知
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。
节点
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