The documentElement
property returns the documentElement of a
document, as an Element object.
documentElement |
Yes | Yes | Yes | Yes | Yes |
document.documentElement
The document's documentElement, as an Element object.
The following code shows how to get the document's documentElement.
<!DOCTYPE html>
<html>
<body>
<p id="demo">test</p>
<button onclick="myFunction()">test</button>
<!--from w ww .j ava 2 s .c om-->
<script>
function myFunction()
{
var x=document.getElementById("demo");
x.innerHTML=document.documentElement.nodeName;
}
</script>
</body>
</html>
The code above is rendered as follows: