HTML | DOM ownerDocument Property
The ownerDocument property returns the top-level document object of the node. Here, the owner document of the node is returned as the document object. It is a read-only property.
Syntax:
node.ownerDocument;
Properties:
- nodeName property: It returns the name of the specified node. If the node is an element node, it will return the tag name else if the node is an attribute node, it will return the attribute name else for different node types, different names will be returned.
syntax:
node.ownerDocument.nodeName;
Return Value: The owner document of the node, is returned as the document object.
Example 1 : Showing nodeName property
<!DOCTYPE html><html><body><h1><center>Geeks <buttononclick="node()">Press</button></center></h1><h4>DOM ownerDocument Property</h4><p>It returns the owner document of the nodeas document object. Click 'Press' to see thenode name of this <p1> element.</p><p1id="PP"></p1><p1id="p2"></p1><p1id="pl"></p1><script>function node() {var x = document.getElementById("PP").ownerDocument.nodeName;document.getElementById("p2").innerHTML ="Node name of the owner document "+"of this <p1> element is";document.getElementById("pl").innerHTML = x}</script></body></html>chevron_rightfilter_noneOutput:
- Before clicking on the button:

- After clicking on the button:

- Before clicking on the button:
- nodeType property: It returns the node type, as a number, of the specified node.
Eg: 1 is returned for an element node and
2 is returned for attribute node.syntax:
node.ownerDocument.nodeType;
Return Value: The owner document of the node, is returned as the document object.
Example-2: Showing nodeType property
<!DOCTYPE html><html><body><h1><center>Geeks <buttononclick="node()">Press</button></center></h1><h4>DOM ownerDocument Property</h4><p>It returns the owner document of the nodeas document object. Click 'Press' to seethe node type of this <p1> element.</p><p1id="PP"></p1><p1id="p2"></p1><p1id="pl"></p1><script>function node() {var x = document.getElementById("PP").ownerDocument.nodeType;document.getElementById("p2").innerHTML ="Node name of the owner document "+"of this <p1> element is";document.getElementById("pl").innerHTML = x}</script></body></html>chevron_rightfilter_noneOutput:
- Before clicking on the button:

- After clicking on the button:

- Before clicking on the button:
Browser Support: The browsers supported by DOM ownerDocument property are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- HTML | DOM id Property
- HTML | DOM dir Property
- HTML | DOM li value Property
- HTML | DOM URL Property
- HTML | DOM specified Property
- HTML | DOM value Property
- HTML | DOM name Property
- HTML | DOM Bdo dir Property
- HTML | DOM domain Property
- HTML | DOM ins cite Property
- HTML | DOM nodeType Property
- HTML | DOM inputEncoding Property
- HTML | DOM offsetHeight Property
- HTML | KeyboardEvent which Property
- HTML | DOM Meter low Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



