You must have come across a situation where you have to make any element
disable or enable.There are couple of ways using them you can
enable/disable any element using jquery. jQuery really makes your task
very easy. In below given example, I have disabled a textbox with id
"txtName".
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" ); |
That's is. This is how you enable or disable any element using jQuery.
No comments:
Post a Comment