我有一个 asp 下拉列表:
<asp:DropDownList runat="server" ID="select_install_type" name="select install type">
<asp:ListItem Values="0" id ="installTypeMeterAndTransmitter" />
<asp:ListItem Values="1" id ="installTypeTransmitterOnly" />
<asp:ListItem Values="2" id="installTypeMeterOnly"/>
</asp:DropDownList>
我在服务器端使用本地化名称填充其项目:
private void FillInstallTypeControl()
{
this.select_install_type.Items[0].Text = CultureResourceHelper.GetConst("meter_and_transmitter");
this.select_install_type.Items[1].Text = CultureResourceHelper.GetConst("transmitter_only");
this.select_install_type.Items[2].Text = CultureResourceHelper.GetConst("meter_only");
}
现在我想写一个简单的jquery方法在选择改变时运行,并根据新的选择做一些事情:
$('#select_install_type').change(function () {
select_install_type.
var selected = ($("#select_install_type").val());
}
我可以获得选定的值,但由于它是本地化的,我不想将其文本与一些字符串进行比较,如下所示:
if (selected == "אאאא")
{ //Do something
}
我怎样才能知道选择了哪些项目?也许得到选定的索引或ID?但我是 jquery 的新手,所以我不知道该怎么做。
提前谢谢了。