--- title: Node.ownerDocument slug: Web/API/Node/ownerDocument translation_of: Web/API/Node/ownerDocument ---
Node.ownerDocument
唯讀屬性會回傳一個此節點所屬的的頂層 document
物件。
document = element.ownerDocument
document
is the {{domxref("Document", "document")}} object parent of the current element.// given a node "p", get the top-level HTML child // of the document object var d = p.ownerDocument; var html = d.documentElement;
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
.
Specification | Status | Comment |
---|---|---|
{{SpecName("DOM4", "#dom-node-ownerdocument", "Node.ownerDocument")}} | {{Spec2("DOM4")}} | |
{{SpecName("DOM3 Core", "core.html#node-ownerDoc", "Node.ownerDocument")}} | {{Spec2("DOM3 Core")}} | No change |
{{SpecName("DOM2 Core", "core.html#node-ownerDoc", "Node.ownerDocument")}} | {{Spec2("DOM2 Core")}} | Initial definition |