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
What is cookie and session in php?
What is mvc php?
Php program to generate fibonacci series?
What is php oops concepts?
What is a http session?
What is an object in php?
Explain what is meant by pear in php?
Explain me what is the meaning of a persistent cookie?
Is php a programming language?
Do you know how to declare an array in php?
Where do I run php code?
What's the difference between using mysql_ functions and pdo?
What is pdo in php why use?
What are the php functions?
How to create a session? How to remove data from a session?