setting a value of ASP:Dropdown using jquery
I am trying to set a value for DDL say
$('#ddlState').val("State"); //State matched the name in DD list value
i have this lin开发者_StackOverflow中文版e in ready function and it works for text boxes but not DDL.
I am also using labelify plugin for text boxes but when i set values like
$('#txtBox').val("Some Value"); //Which is not same as title value
the some value is showing in the grey color.
Any clue?
Well for starters, .NET doesn't render the controls as
$('ddlState');
Try doing this:
$('#<% ddlState.ClientID %>').val('State');
Check out this answer:
Adding options to a <select> using jQuery?
精彩评论