Change background color onmouseover with Javascript

Submitted by html_freak on Wed, 06/24/2009 - 11:33

You can change background color of this div just bringing your mouse over colors.

00ff33
66ccff
ffff99
00ffcc

Code of Javascript/HTML:


<script language="javascript">
function change_background_color(c){
document.getElementById('div2change').style.backgroundColor= '#'+c;
}
</script>

<div id="div2change" style="background-color: #cde; padding: 10px ; text-align: center;">

You can change background color of this div just bringing your mouse over colors.

<a style="background-color: #0f3;" class="cc" onMouseOver="change_background_color('00ff33'); ">00ff33</a>
<a style="background-color: #6cf;" class="cc" onMouseOver="change_background_color('66ccff'); ">66ccff</a>
<a style="background-color: #ff9;" class="cc" onMouseOver="change_background_color('ffff99'); ">ffff99</a>
<a style="background-color: #0fc;" class="cc" onMouseOver="change_background_color('00ffcc'); ">00ffcc</a>

</div>

Add new comment