How to enable and disable all control of page using jQuery?


In this article I have explained about How to enable and disable all control of page using jQuery. Each steps I have clearly explained in this article.

In this article I have explained about How to enable and disable all control of page using jQuery. Each steps I have clearly explained in this article .
jQuery provides (*) selector, which selects all the elements of the web page.
By using this selector we can enable or disable the web page controls. Herewith i have explained with simple example


<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script src="jquery-1.2.6.js" type="text/javascript"></script>
<script type="text/javascript">

$(document).ready(function()
{
$("#Button1").toggle(function()
{
$("*").attr("disabled", "disabled");
$(this).val('Click me to enable');
$(this).attr("disabled", "");},

function()
{
$("*").attr("disabled", "");
$(this).val('Click me to disable');
});
});


</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" Text="Click me to disable" runat="server" />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:HyperLink ID="HyperLink1" runat="server">HyperLink</asp:HyperLink>
</div>
</form>
</body>
</html>


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: