Javascript Reference - HTML DOM ownerDocument Property








The ownerDocument property returns the owner document of a node as a Document object.

Browser Support

The ownerDocument property is supported in all major browsers.

ownerDocument Yes Yes Yes Yes Yes

Syntax

node.ownerDocument

Return Value

The owner document of the node as a Document object.





Example

The following code shows how to get the ownerDocument of an element.


<!DOCTYPE html>
<html>
<body>
<!-- ww  w  .j  a va  2s. c om-->
<p id="demo">test</p>

<button onclick="myFunction()">test</button>

<script>
function myFunction()
{
    var x=document.getElementById("demo");  
    x.innerHTML=x.ownerDocument.nodeType;
}
</script>

</body>
</html>

The code above is rendered as follows: