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