How to set HTML document background color with JavaScript

1 Answer

0 votes
<!DOCTYPE html>
<html>
<body>

<button onclick="SetBackgroundColor()">Set Background Color</button>

<script>
function SetBackgroundColor() {
  document.body.style.backgroundColor = "green";
}
</script>

</body>
</html>

 



answered Jan 11, 2019 by avibootz

Related questions

1 answer 254 views
1 answer 254 views
1 answer 218 views
1 answer 249 views
1 answer 265 views
1 answer 319 views
...