Style backgroundColor 屬性
實例
設置文檔的背景顏色:
document.body.style.backgroundColor="#f3f3f3";
定義和用法
backgroundColor 屬性設置或返回元素的背景顏色。
流覽器支持





所有主要流覽器都支持 backgroundColor 屬性。
注意:IE7 及更早的版本不支持 "inherit" 值。IE8 只有規定了 !DOCTYPE 才支持 "inherit"。IE9 支持 "inherit"。
語法
設置 backgroundColor 屬性:
	element.style.backgroundColor="color|inherit|transparent"
返回 backgroundColor 屬性:
	element.style.backgroundColor
屬性值
| 值 | 描述 | 
|---|---|
| color | 規定背景顏色。在 CSS 顏色值中尋找可能的顏色值的完整列表。 | 
| inherit | 背景顏色從父元素繼承。 | 
| transparent | 默認。背景顏色是透明的(基本內容將會穿透)。 | 
技術細節
| 默認值: | transparent | 
|---|---|
| 返回值: | 一個代表背景顏色的字串 | 
| DOM 版本 | Core Level 1 | 
 Style 對象
 Style 對象
			