Fastest way to change page background color using JS?
What开发者_如何转开发's the smallest and fastest way to modify a document's background color using javascript? it should be cross browser.
I tried the following which didn't work in firebug:
document.body.bgcolor = "#eee";
document.documentElement.bgcolor = "#eee";
Use the backgroundColor
CSS property:
document.body.style.backgroundColor = "#eeeeee";
This should work:
document.body.style.backgroundColor = "#eee";
Here is a live demo.
精彩评论