HTML DOM backgroundColor 属性
定义和用法
backgroundColor 属性设置元素的背景颜色。
语法:
- Object.style.backgroundColor=color-name|color-rgb
- |color-hex|transparent
实例
本例设置 body 的背景色:
- <html>
- <head>
- <style type="text/css">
- body
- {
- background-color:#B8BFD8;
- }
- </style>
- <script type="text/javascript">
- function changeStyle()
- {
document.body.style.backgroundColor="#FFCC80";
- }
- </script>
- </head>
- <body>
- <input type="button" onclick="changeStyle()"
- value="Change background color" />
- </body>
- </html>