Add default option to ASP.NET Dropdown list using jQuery
Sometimes It is required to add default option like "Please Select" or "Select" in Dropdown list. Below is a simple jQuery code to "add default option to ASP.NET Dropdown list using jQuery".
//Code Starts $(document).ready(function(){ var defaultOpt = "<option selected='selected' value='-1'>--Select--</option>" $('#<%=ddlCountry.ClientID %>').prepend(defaultOpt); }) //Code Ends
And if you want to add default option to all the dropdown list on the page then use below jQuery code.
//Code Starts $(document).ready(function(){ var defaultOpt = "<option selected='selected' value='-1'>--Select--</option>" $('select').prepend(defaultOpt); }) //Code Ends
Feel free to contact me for any help related to jQuery, I will gladly help you.