Javascript examples for CSS Style Property:backgroundColor
The backgroundColor property sets or gets the element background color.
Value | Description |
---|---|
color | Set the background color. |
transparent | Default value. The background color is transparent |
initial | Sets this property to its default value. |
inherit | Inherits this property from its parent element. |
Item | Value |
---|---|
Default Value: | transparent |
Return Value: | A String, representing the background color |
CSS Version | CSS1 |
Get a background color for a document:
<!DOCTYPE html> <html> <body style="background-color:yellow;"> <h1>Hello World!</h1> <button type="button" onclick="myFunction()">Get background color</button> <script> function myFunction() {//from ww w . j a v a 2s . c o m console.log(document.body.style.backgroundColor); } </script> </body> </html>