JQuery Change Div Background Color Randomly
How to change background color of div by JQuery:
In this post we explain randomly change the back ground
color of div at run time.
JQuery Function of change background:
function changecolor() {
var colors = ["#B40404",
"#0000FF", "#FE2E9A",
"#FF0080", "#2EFE2E",
];
var rand = Math.floor(Math.random() * colors.length);
$('#controls-wrapper').css("background-color",
colors[rand]);
setTimeout('changecolor()', 1000);
}
JQuery Related Other Post:
- Check Uncheck all asp.net CheckBox in asp.net using jQuery
- Example of jQuery Validate on Radiobuttonlist in Asp.Net using C#
- Example jQuery Validate on CheckBoxList using C#
- Check Uncheck all html CheckBox controls using jQuery:
- fill data into Dropdown list by using Jquery
- Validate ASP.Net RadioButtonList using JavaScript Example
- Example of jQuery Validate on Radiobuttonlist in Asp.Net using C#
- Example jQuery Validate on CheckBoxList using C#
- Check Uncheck all asp.net CheckBox in asp.net using jQuery
- Check Uncheck all html CheckBox controls using jQuery:
- Asp.net CheckBoxList using jQuery.
- Cropping image using jQuery in asp.net
- Displaying the textbox value in javascript Messagebox
- Get selected radio button values using JQuery.
- How do you do html text encodes using JavaScript
JQuery Example of change background:
<%@ Page
Language="C#"
AutoEventWireup="true"
CodeFile="divExample.aspx.cs"
Inherits="divExample"
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD
XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(document).ready(function () {
changecolor();
});
function changecolor() {
var colors = ["#B40404",
"#0000FF", "#FE2E9A",
"#FF0080", "#2EFE2E",
];
var rand = Math.floor(Math.random() * colors.length);
$('#controls-wrapper').css("background-color",
colors[rand]);
setTimeout('changecolor()', 1000);
}
</script>
<style type="text/css">
.style1
{
text-decoration: underline;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="controls-wrapper" align="center">
<p>
<h1><span class="style1">Hello </span> <br class="style1"
/>
<span class="style1">Friends
</span> </h1>
welcome to this <a href="http://asp-net-by-parijat.blogspot.in/">Asp.net
tutorial.</a><br />
<br />
<br />
<br />
</p>
</div>
</form>
</body>
</html>
Other Examples:
- Limit Number of Characters in a TextArea using jQuery
- Limitation of Characters in Textbox or TextArea in asp.netusing jquery:
- jquery disable or Enable submit button after validation
- Enable Disable Submit Button using jQuery
- JQuery UI Datepicker (Calendar) with asp.net textbox
- Get current datetime in jquery and javaScript.
- jQuery modal dialog with postback in asp.net
- how to add captcha in Asp.net programming
- Example of DropDownList inside GridView
- Introduction of Asp.net grid view Control.
- Example of Templatefield in asp.net gridview.
- Show gridview Row Details And Give Example.
- Ckeck box list example using javascript in grid.
- Example of DropDownList inside GridView control
- Example of Crystal report(Crystal_report_in asp.net programming )
- How to Make a HTML Table by C# code in asp.net programming
- Example of C# for Bind Data to asp.net Textbox inside gridview control
Comments
Post a Comment