jQuery实现CheckBox全选、全不选以及获取全选Value值
$("#btnCheckBox").click(function () {
if ($("#btnCheckBox").prop("checked")) {
$("input[name='libCheckBox']").each(function () {
$(this).prop("checked", true);
});
}
else {
$("input[name='libCheckBox']").each(function () {
$(this).prop("checked", false);
});
}
});
获取CheckBox全选Value值
//获取所有选中ID
function getCheckIptVal() {
var ids = "";
if ($("input[name='libCheckBox']").length > 0) {
$("input[name='libCheckBox']").each(function () {
//找到已选中数据
if ($(this).prop('checked')) {
//得到已选中数据
if (ids == "") {
ids += $(this).val();
}
else {
ids += "," + $(this).val();
}
}
});
}
return ids;
}