mcl*_*dtk 2 asp.net jquery radiobuttonlist
我有以下ASP.NET RadioButtonList:
<asp:RadioButtonList ID="rbl" runat="server">
<asp:ListItem Text="Type1" Value="1" />
<asp:ListItem Text="Type2" Value="2" />
</asp:RadioButtonList>
Run Code Online (Sandbox Code Playgroud)
我想通过客户端jquery函数以编程方式选择列表中的项目(简化版本):
function BindWidget(widget) {
// Type property of Widget is an int.
$("#<%=rbl.ClientID%>").selectItemByValue(widget.Type);
}
Run Code Online (Sandbox Code Playgroud)
理想情况下,有一些函数 - 在上面的代码中我提出了selectItemByValue - 它按给定的值选择RadioButtonList中的一个项.jquery是否内置了类似的功能?如果没有,我应该如何实现所需的功能?
试试这个.
$('#<%=rbl.ClientID %>').find("input[value=" + widget.Type + "]").attr("checked", "checked");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9786 次 |
| 最近记录: |