The ownerDocument
property returns the owner document of a node as a Document object.
The ownerDocument
property is supported in all major browsers.
ownerDocument |
Yes | Yes | Yes | Yes | Yes |
node.ownerDocument
The owner document of the node as a Document object.
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: