I have a html field.
<select name="select-states" disabled="disabled"><option value="">Choose State »</option></select>
initially the field is disabled, i want to enable or disable it based on events. to enable it i am using the following jQuery which works fine.
$('select[name="select-states"]').removeAttr('disabled');
I want to re-enable it using jQuery, for which i tried using this which does not work.
$('select[name="select-states"]').attr('disabled');
What am i missing? which is the correct syntax for this?
thank you
In your code, you provide only one parameter to
.attr(). This indicates that the function should just return the value for thedisabledattribute of that element.To set the
disabledattribute, provide the attribute name (first parameter) along with a value (second parameter):