javascript backgroundColor property


  Translation results:

UK [ˈbækɡraund ˈkʌlə] US [ˈbækˌɡraʊnd ˈkʌlɚ]

Background color

javascript backgroundColor propertysyntax

Function:Set the background color of the element.

Syntax: Object.style.backgroundColor=color-name|color-rgb|color-hex|transparent

javascript backgroundColor propertyexample

<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>

Run instance »

Click the "Run instance" button to view the online instance

Home

Videos

Q&A