0

I have this script that here that I'll program later to continously change the background color, but for some reason it does not work at all. It's not throwing any errors either

<html>
<body id = "BGCOLOR" bgcolor = rgb(0,0,0); >
<script>
function ChangeColor(){
    document.getElementById("BGCOLOR").bgcolor = "rgb(0,50,0)";
}
ChangeColor();
</script>
</body>
</html>
  • You refer this http://stackoverflow.com/questions/197748/how-do-i-change-the-background-color-with-javascript – Maths RkBala Aug 23 '16 at 05:05
  • Possible duplicate of [How do I change the background color with JavaScript?](https://stackoverflow.com/questions/197748/how-do-i-change-the-background-color-with-javascript) – showdev Jul 05 '19 at 07:57

2 Answers2

0
document.body.style.backgroundColor = "red";

for more refrence check http://www.w3schools.com/jsref/prop_style_backgroundcolor.asp

Amit Kumar Pawar
  • 3,252
  • 1
  • 20
  • 27
0

friend try this code

 <html>
    <body id = "BGCOLOR" bgcolor = rgb(0,0,0); >
    <script>
    function ChangeColor(){
        document.body.style.backgroundColor = "rgb(0,50,0)";
    }
    ChangeColor();
    </script>
    </body>
    </html>
sms247
  • 4,404
  • 5
  • 35
  • 45