Returns the document object that contains the current node.
Elements and attributes always have an owner document regardless of they are inserted into (appendChild, insertBefore, setAttributeNode) or removed form (removeChild, removeAttributeNode) the document tree. When a node is created (createElement, createAttribute, createComment, etc.) its ownerDocument property is set to the document object on which the create method was called. Insert and remove operations do not affect the owner document of a node. If you need to move a node to another document, use the adoptNode and importNode methods.
You can find the related objects in the Supported by objects section below.
This property is read-only.
Reference to the container document object.
Default: this property has no default value.
Example HTML code 1:
This example illustrates the use of the ownerDocument property:
Did you find this example helpful?
User Contributed Comments