change the div background color on every refresh

by Mohan 2012-09-17 16:28:28

<html>
<body onload="changeColor()">
<script type="text/javascript">
var color=new Array(6);
color[0]="green";
color[1]="#eeeeee";
color[2]="#99CCFF";
color[3]="lavender";
color[4]="pink";
color[5]="#669999";
function changeColor()
{
var ranNum= Math.floor(Math.random()*6);
document.getElementById('div1').style.backgroundColor=color[ranNum];
}
</script>
<div id="div1" name="div1"
style="height:500px;"><center>Changing Color of
div</center></div>
</body>
</html>
1004
like
0
dislike
0
mail
flag

You must LOGIN to add comments