$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?
I used @gnarf answer and added it as function
Then use like this
Sometimes you need to disable/enable the form element like input or textarea. Jquery helps you to easily make this with setting disabled attribute to "disabled". For e.g.:
To enable disabled element you need to remove "disabled" attribute from this element or empty it's string. For e.g:
refer :http://garmoncheg.blogspot.fr/2011/07/how-to-disableenable-element-with.html
Disable:
Enable:
You can put this somewhere global in your code:
And then you can write stuff like:
Just for the sake of new conventions && making it adaptable going forward (unless things change drastically with ECMA6(????):
and
2018, without JQuery (ES6)
Disable all
input
:Disable
input
withid="my-input"
The question is with JQuery, it's just FYI.