In many cases we need to change the status and it is done by the change of text color change; you can achive it by simple code in Jquery. Here just need to play with Css method of jquery and assign the color what you need;
You just need to take the reference of Jquery js file into your application or page;
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
Here is the code to change the color of text;
@Jquery code to change the color of text;
<script type="text/javascript">
//Check box checked
$(document).ready(function () {
$("#Button1").click(function () {
$("#Label1").css('color', 'red');
});
$("#Button2").click(function () {
$("#Label1").css('color', 'green');
});
});
</script>
@Aspx, html code
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<input id="Button1" type="button" value="Red" />
<input id="Button2" type="button" value="Green" />
<br />
@Full code to change the color of text of label;
<head runat="server">
<title>Change Image src </title>
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
//Check box checked
$(document).ready(function () {
$("#Button1").click(function () {
$("#Label1").css('color', 'red');
});
$("#Button2").click(function () {
$("#Label1").css('color', 'green');
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table width="60%" align="center">
<tr>
<td colspan="2" align="left">
<h1>
Label color change</h1>
</td>
</tr>
<tr>
<td align="right">
</td>
<td align="left">
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<input id="Button1" type="button" value="Red" />
<input id="Button2" type="button" value="Green" />
<br />
</td>
</tr>
</table>
</div>
</form>
</body>
@output screen;
No comments:
Post a Comment