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