Javascript DOM HTML Node nodeType Property for <body> element

Introduction

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.

View in separate window

<!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>



PreviousNext

Related