开发者

setting a value of ASP:Dropdown using jquery

开发者 https://www.devze.com 2023-02-24 12:44 出处:网络
I am trying to set a value for DDL say $(\'#ddlState\').val(\"State\");//State matched the name in DD list value

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消