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";
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";
Share
Improve this question
asked Feb 24, 2011 at 12:32
Robin RodricksRobin Rodricks
114k147 gold badges414 silver badges617 bronze badges
2 Answers
Reset to default 9Use the backgroundColor
CSS property:
document.body.style.backgroundColor = "#eeeeee";
This should work:
document.body.style.backgroundColor = "#eee";
Here is a live demo.