Introduction
Here I will explain how to generate random colors for div using JavaScript and change color of div at regular intervals of time using JavaScript in asp.net.
Here I will explain how to generate random colors for div using JavaScript and change color of div at regular intervals of time using JavaScript in asp.net.
To
implement this we need to write the code like as shown below
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Generate Random Colors using javascript</title>
<script type="text/javascript">
// Run function for every second
of timer
setInterval(rgbcolors, 1000);
function rgbcolors() {
// rgb string generation
var col = "rgb("
+ Math.floor(Math.random() * 255) + ","
+ Math.floor(Math.random() * 255) + ","
+ Math.floor(Math.random() * 255) + ")";
//change the text color with the
new random color
document.getElementById("divstyle").style.color = col;
}
</script>
</head>s
<body>
<form id="form1"
runat="server"
>
<div id="divstyle"
style="font:bold 24px verdana">http://gohilinfotech.blogspot.in</div>
</form>
</body>
</html>
|
0 comments :
Post a Comment