Element ownerDocument Property - Javascript DOM

Javascript examples for DOM:Element ownerDocument

Description

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

Return Value

The owner document of the node, as a Document object

The following code shows how to get the node type of the owner document of a <p> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p id="myP">test</p>

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

<p id="demo"></p>

<script>
function myFunction() {/*from w  ww.j  a v  a 2  s  .c  o  m*/
    var x= document.getElementById("myP").ownerDocument.nodeType;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials