Javascript examples for DOM:Document documentElement
The documentElement property returns the <html> element, as an Element object.
This property is read-only.
document.body element returns the <body> element, while the document.documentElement returns the <html> element.
The document's documentElement, as an Element object
The following code shows how to return the documentElement of the document, as a node name:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">display the node name of the documentElement</button> <p id="demo"></p> <script> function myFunction() {//from ww w . j a va2s . c o m var x = document.documentElement.nodeName; document.getElementById("demo").innerHTML = x; } </script> </body> </html>