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.
Description:
In previous articles I explained jQuery Change background color of div, jQuery fadein fadeout effect, jQuery get current page url and title, jQuery create rounded corners for textbox and many articles relating to JavaScript, jQuery, asp.net. Now I will explain how to generate random colors for div using JavaScript in asp.net.
In previous articles I explained jQuery Change background color of div, jQuery fadein fadeout effect, jQuery get current page url and title, jQuery create rounded corners for textbox and many articles relating to JavaScript, jQuery, asp.net. Now I will explain how to generate random colors for div using JavaScript in asp.net.
<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">Aspdotnet-suresh.com</div>
</form>
</body>
</html>
|
Live
Demo
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
2 comments :
blog has lot of information.... gud methodolgy
Try your methrod, but the color can not be changed.
Note: Only a member of this blog may post a comment.