The read-only ownerDocument
property of the Node
interface returns the top-level document object of the node.
The read-only ownerDocument
property of the Node
interface returns the top-level document object of the node.
A Document
that is the top-level object in which all the child nodes are created.
If this property is used on a node that is itself a document, the value is null
.
js
// Given a node "p", get the top-level HTML // child of the document object const d = p.ownerDocument; const html = d.documentElement;
Specification |
---|
DOM Standard # ref-for-dom-node-ownerdocument① |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
ownerDocument |
1 | 12 | 91–9TheownerDocument of doctype nodes (that is, nodes for which Node.nodeType is Node.DOCUMENT_TYPE_NODE or 10) is null . |
6 | ≤12.1 | 1 | 4.4 | 18 | 94–9TheownerDocument of doctype nodes (that is, nodes for which Node.nodeType is Node.DOCUMENT_TYPE_NODE or 10) is null . |
≤12.1 | 1 | 1.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Node/ownerDocument