How to Disable DropDown List Item using jQuery

In this post, I will show you how you can disable specific items of the DropDown/ComboBox/Select element using jQuery. To disable any item, just need to add attribute "disabled" with value "disabled" to the list item.

//Code Starts
$(document).ready(function() {   
    $("#ddlList option[value='jquery']").attr("disabled","disabled");
});?
//Code Ends

See result below.

You can also disable item by their Text, not by value. Below jQuery code will disable the List Item with text "HTML"

//Code Starts
$(document).ready(function() {   
   $('#ddlList option:contains("HTML")').attr("disabled","disabled");
});?
//Code Ends

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



Responsive Menu
Add more content here...