开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜