在ASP.NET CheckBoxList中,有没有办法确定是否使用jquery选中了某个特定的复选框?我需要知道是否选中了"All“,例如,通过值或标签文本。
<asp:CheckBoxList ID ="ToyotaModels" runat="server">
<asp:ListItem Value = "0">Corolla<asp:ListItem>
<asp:ListItem Value = "1">Matrix<asp:ListItem>
<asp:ListItem Value = "2">Tundra</asp:ListItem>
<asp:ListItem Value = "3">Prius</asp:ListItem>
<asp:ListItem Value = "4">All</asp:ListItem>
</asp:CheckBoxList>发布于 2010-03-11 07:13:44
这应该会在单击时显示选中的复选框:
$('input:checked').click().each(function() {
//process the checkbox stuff here..
});编辑:基于注释
function processChecks()
{
$('input:checked').each(function()
{
alert($(this).val();
});
};发布于 2010-03-11 07:01:19
您必须查看由ASP.Net的CheckboxList生成的HTML。在javascript中,输入的容器ID是复选框,如下所示:
<%= ToyotaModels.ClientID %>每个复选框输入都将_X附加到ID,其中X是数字复选框。因此,要查看第一个项目(花冠)是否已选中,可以执行以下操作:
$('<%= "#" + ToyotaModels.ClientID + "_0" %>').is(":checked")发布于 2010-03-11 07:02:11
在jQuery中,您可以使用.is(":checked")函数来完成此任务。
https://stackoverflow.com/questions/2421204
复制相似问题