开发者

Fastest way to change page background color using JS?

开发者 https://www.devze.com 2023-02-13 17:25 出处:网络
What开发者_如何转开发\'s the smallest and fastest way to modify a document\'s background color using javascript? it should be cross browser.

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

精彩评论

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