Javascript Reference - HTML DOM documentElement Property








The documentElement property returns the documentElement of a document, as an Element object.

Browser Support

documentElement Yes Yes Yes Yes Yes

Syntax

document.documentElement

Return Value

The document's documentElement, as an Element object.

Example

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: