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

<!DOCTYPE html>

 function red()

 function red1()

 function red2()


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


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.

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

In the HTML (attached to a tag)


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

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