我有多个复选框,第一个复选框值是全选。我的jQuery代码是
$(".checkboxFilter input:checkbox:first").change().toggle(function () {
alert("inside first toggle");
$(".checkboxFilter").find(':checkbox').prop("checked", true);
}, function () {
alert("inside second toggle");
$(".checkboxFilter").find(':checkbox').prop("checked", false);
});问题是,当我渲染页面时,默认情况下,选择全部按钮是选中的,但没有选中其他选项。当我再次单击select all复选框时,它会选择all,当我再次单击select all按钮时,它会取消选择all,但select all按钮仍然保持选中状态。有人能帮我吗?
发布于 2011-09-07 01:22:32
不要使用toggle,只要使用change就可以了。看看这个
工作
$(".checkboxFilter input:checkbox:first").change(function () {
$(".checkboxFilter").find(':checkbox').prop("checked", this.checked);
});发布于 2011-09-07 00:38:18
您应该将"Select All“的默认状态设置为”non“或”everything to checked“。
https://stackoverflow.com/questions/7323197
复制相似问题