Sometimes, we want to change the background color with JavaScript.
In this article, we’ll look at how to change the background color with JavaScript.
How to change the background color with JavaScript?
To change the background color with JavaScript, we can set the style.background
property of an element.
For instance, we write
document.body.style.background = color;
to set the body element’s background color to color
.
We get the body element’s background color with
document.body.style.background
Conclusion
To change the background color with JavaScript, we can set the style.background
property of an element.