Disable/Enable an element using jQuery
Approach 1
1
$("#txtName").attr("disabled", true);
Approach 2
1
$("#txtName").attr("disabled", "disabled");
If you wish to enable any element then you just have to do opposite of what you did to make it disable. However jQuery provides another way to remove any attribute.
Approach 1
1
$("#txtName").attr("disabled", false);
Approach 2
1
$("#txtName").attr("disabled", "");
Approach 3
1
$("#txtName").removeAttr("disabled");
Approach 1
1
$("#txtName").attr("disabled", true);
Approach 2
1
$("#txtName").attr("disabled", "disabled");
If you wish to enable any element then you just have to do opposite of what you did to make it disable. However jQuery provides another way to remove any attribute.
Approach 1
1
$("#txtName").attr("disabled", false);
Approach 2
1
$("#txtName").attr("disabled", "");
Approach 3
1
$("#txtName").removeAttr("disabled");
0 comments:
Post a Comment