This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
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.
// Given a node "p", get the top-level HTML // child of the document object const d = p.ownerDocument; const html = d.documentElement;
| Specification |
|---|
| DOM> # ref-for-dom-node-ownerdocument①> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
ownerDocument |
1 | 12 | 91–9TheownerDocument of doctype nodes (that is, nodes for which Node.nodeType is Node.DOCUMENT_TYPE_NODE or 10) is null. |
≤12.1 | 1 | 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 | 4.4 | 1 |
© 2005–2025 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