Table of contents
- 1. Summary
- 2. Syntax
- 3. Example
- 4. Notes
- 5. Browser compatibility
- 5.1. Gecko notes
- 6. Specification
Summary
The ownerDocument property returns the top-level document object for this node.
Syntax
document = element.ownerDocument
documentis thedocumentobject parent of the current element.
Example
// given a node "p", get the top-level HTML child // of the document object d = p.ownerDocument; html = d.documentElement;
Notes
The document object returned by this property is the main object with which all the child nodes in the actual HTML document are created. If this property is used on a node that is itself a document, the result is null.
Browser compatibility
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | ? | ? | ? | ? | ? |
| Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|
| Basic support | ? | ? | ? | ? | ? |
Gecko notes
Starting in Gecko 9.0 (Firefox 9.0 / Thunderbird 9.0 / SeaMonkey 2.6)
, the ownerDocument of doctype nodes (that is, nodes for which Node.nodeType
is Node.DOCUMENT_TYPE_NODE or 10) is no longer null. Instead, the ownerDocument is the document on which document.implementation.createDocumentType() was called.
Mozilla Developer Network