Javascript examples for DOM HTML Element:Body
The Body object represents an HTML <body> element.
You can access a <body> element by using getElementsByTagName():
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">set the background color of the document</button> <p id="demo"></p> <script> function myFunction() {//from w w w.j av a 2s . co m var x = document.getElementsByTagName("BODY")[0]; x.style.backgroundColor = "#EEE"; } </script> </body> </html>