Reputation: 51
In my css a background-color is defined set as white, but I want to change color dynamically body of page.
How do you do that? my CSS file:
body {
color: #333;
background-color: #FFF;
}
my javascript code :
function init()
{
document.body.style.zoom="90%";
document.body.color="white";
}
Thank you.
Upvotes: 5
Views: 20491
Reputation: 388436
For changing the style you need to access the style property, and the property of background-color
is backgroundColor
document.body.style.backgroundColor="white"
Upvotes: 2
Reputation: 11568
document.body.style.background = 'yourColor';
How do I change the background color with Javascript?
Upvotes: 2