<html>
<body>
<p id="demo">Click the button get the node type of the ownerDocument of this &lt;p&gt; element</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction()
{
var x=document.getElementById("demo");
x.innerHTML=x.ownerDocument.nodeType;
}
</script>
</body>
</html>