W3cubDocs

/Web APIs

Node: ownerDocument property

The read-only ownerDocument property of the Node interface returns the top-level document object of the node.

Value

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.

Example

js

// Given a node "p", get the top-level HTML
// child of the document object

const d = p.ownerDocument;
const html = d.documentElement;

Specifications

Browser compatibility

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 9
1–9The ownerDocument 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 9
4–9The ownerDocument 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