How to Enable Select Dropdown Option in jQuery

If you are working with select dropdown box in HTML. And if the select option box is non-selectable or disabled. Or you want to make this select dropdown option box selectable or enable. You can do this with jQuery’s prop(‘disabled’, true) method.

This tutorial guide will show you how to enable select dropdown option box using jQuery, which is disabled.

Enable a Select Option Box using jQuery

To enable a select dropdown option box using jQuery, you can use the .prop() method. The .prop() method is used to get or set the value of a property for a selected element. To enable a select dropdown option box, you need to set the “disabled” property of the select box to “false”. Here’s the code:

//code enable select dropdown option in jquery
$(document).ready(function() {
  $("#mySelectBox").prop("disabled", true);
});

In the above code, the $(document).ready() method is used to make sure that the DOM is fully loaded before the script is executed. The $("#mySelectBox") selector is used to select the select box element with the id mySelectBox. The .prop() method is used to set the “disabled” property of the select box to “false”, which will enable the select box.

“If you want to disable selected option in select, you can set the “disabled” attribute true of the option element. Here’s an example code snippet:

//code disable select dropdown option in jquery

$(document).ready(function() {
  $("#mySelectBox").prop("disabled", true);
});

In the above code, the $(document).ready() method is used to make sure that the DOM is fully loaded before the script is executed. The $("#mySelectBox") selector is used to select the select box element with the id mySelectBox. The .prop() method is used to set the “disabled” property of the select box to “false”, which will disable the select box again.

Conclusion

In this tutorial, you learned how to enable a select dropdown option box using jQuery. The .prop() method is used to set the “disabled” property of the select option box to “false”, which will enable the select dropdown option box. And if want to disable again select dropdown option box, you can set the “disabled” property to “true”

Recommended jQuery Ajax Tutorials

div class=”gen-info-box”>JQuery Automatically Refresh or Reload a Page Tutorial