Disable/Enable an element using jQuery

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
$("#txtName").attr("disabled", true);
Approach 2
$("#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
$("#txtName").attr("disabled", false); 
Approach 2
$("#txtName").attr("disabled", ""); 
Approach 3
That's is. This is how you enable or disable any element using jQuery.

Feel free to contact me for any help related to jQuery. I will gladly help you.

Nothing shocks me, I'm a Software Engineer. And I am not young enough to know everything. I live in World Wide Web and from there take care of this website. This website communicates about my work, learning and experience. I believe life is short, and it is for loving, sharing, learning and connecting. So lets connect..