Get Body Element using the document.body property. - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Body

Description

Get Body Element using the document.body property.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">set the background color of the document</button>

<p id="demo"></p>

<script>
function myFunction() {//from  w ww .  j  a  va  2  s . c  o  m
    var x = document.body;
    x.style.backgroundColor = "#EEE";
}
</script>

</body>
</html>

Related Tutorials