How to Disable DropDown List Item 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

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

Comments

Popular posts from this blog

GROUP BY, CUBE, ROLLUP and SQL SERVER 2005

How to get content of Ckeditor & Fckeditor using Javascript

How to Fix Error- Sys.WebForms.PageRequestManagerTimeoutException - The server request timed out