can we get red color background using document.bgColor="rgb(255,0,0)"; line?

<!DOCTYPE html>
<html>
<body>
<script>

 function red()
{
 document.bgColor="#FF0000";
}


 function red1()
{
 document.bgColor="red";
}

 function red2()
{
 document.bgColor="rgb(255,0,0)";
}

</script>

<button type="button" onclick=" red(); ">RED background</button>
<button type="button" onclick=" red1(); ">RED background</button>
<button type="button" onclick=" red2(); ">RED background</button>

</body>
</html>

Instead of “bgColor” try “background-color” and “backgroundColor” with “style”.

hi sir,
inside a <script> and inside a function, background-color using style doesnt works…please help me find a solution.
<script>

style = “document.background-color: rgb(255,0,0);”> <p>inside a style function tag does not works </p>
</div>
</script>

In the HTML (attached to a tag)

style=“background-color:rgb(255,0,0);”

In JavaScript (attached to the node you want it to apply to)

style.backgroundColor = ‘rgb(255,0,0)’;