Get the node type of the <body> element:
var x = document.body.nodeType;
Click the button to get the node type of the body element.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from w w w . j a va 2 s. c om*/ var x = document.body.nodeType; document.getElementById("demo").innerHTML = x; } </script> </body> </html>