How to work with document.body in JavaScript?

HTMLJavascriptProgramming Scripts

Use the document.body property in JavaScript to get the body of the document i.e. <body> tag.

Example

You can try to run the following code to implement document.body property in JavaScript.

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <title>JavaScript Example</title>
   </head>
   <body>
      <p>Demo Text</p>
      <script>
         document.body.style.backgroundColor = "blue";
      </script>
   </body>
</html>
raja
Published on 26-Feb-2018 14:39:37
Advertisements