$input.disabled = true;
or
$input.disabled = "disabled";
Which is the standard way? And, conversely, how do you enable a disabled input?
$input.disabled = true;
or
$input.disabled = "disabled";
Which is the standard way? And, conversely, how do you enable a disabled input?
There are many ways using them you can enable/disable any element :
Approach 1
Approach 2
If you are using jQuery 1.7 or higher version then use prop(), instead of attr().
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
Approach 2
Approach 3
Again, if you are using jQuery 1.7 or higher version then use prop(), instead of attr(). That's is. This is how you enable or disable any element using jQuery.
Use like this,
Update for 2018:
Now there's no need for jQuery and it's been a while since
document.querySelector
ordocument.querySelectorAll
(for multiple elements) do almost exactly same job as $, plus more explicit onesgetElementById
,getElementsByClassName
,getElementsByTagName
Disabling one field of "input-checkbox" class
or multiple elements