使用jquery在按钮单击时选择一个下拉选项 [英] use jquery to select a dropdown option on button click
本文介绍了使用jquery在按钮单击时选择一个下拉选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用jQuery通过点击一个按钮来选择一个选项,比如说第3项,在DropDownList中,然后让DropDownList框改变它的值,比如'44'。
I want to use jQuery to select an option, say the 3th item, in a DropDownList by clicking a button, then have the DropDownList box change it's value, say '44'.
<asp:DropDownList ID="DropDownList2" runat="server"
onselectedindexchanged="DropDownList2_SelectedIndexChanged">
<asp:ListItem Selected="True">SELECT</asp:ListItem>
<asp:ListItem Value="1">23</asp:ListItem>
<asp:ListItem Value="2">32</asp:ListItem>
<asp:ListItem Value="3">44</asp:ListItem>
<asp:ListItem Value="4">61</asp:ListItem>
</asp:DropDownList>
推荐答案
这可能会帮助您
var dropDownList2ID = "#<%=DropDownList2.ClientID%>";
var buttonID = "#idOfButton";
//...
$(buttonID).click(function() {
$(dropDownList2ID).val(3);
});
这篇关于使用jquery在按钮单击时选择一个下拉选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文