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.
SHARE

Nothing shocks me, I'm a Software Engineer. And I am not young enough to know everything. I live in World Wide Web and from there take care of this website. This website communicates about my work, learning and experience. I believe life is short, and it is for loving, sharing, learning and connecting. So lets connect..