how to change the div background color on every
refresh..guys can u help me out.
Answer Posted / guest
Try with the following code.
<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>
| Is This Answer Correct ? | 27 Yes | 5 No |
Post New Answer View All Answers
Is facebook still written in php?
What is a static variable in php?
What is member variable?
Write a statement to show the joining of multiple comparisons in php?
What is empty php?
How to find the position of the first occurrence of a substring in a string?
How do I find environment variables?
Why would we use === instead of ==?
What is session cookies php?
What does php do?
How is it possible to set an infinite execution time for php script?
Which php framework is in demand?
Which have the fastest execution between mysql_fetch_array() and mysql_fetch_assoc()
Is php a low level language?
How to retrieve the original query string?