获取已选中的:
var checkedArr = [];
$("input[name='xxx']:checked").each(function() {
checkedArr.push($(this).val());
});
获取未选中的:
var notCheckedArr = [];
$("input[name='xxx']:not(:checked)").each(function() {
notCheckedArr.push($(this).val());
});
清空已选项:
$("input[name='xxx']").prop("checked",false);
初始化默认全选:
$("[name='service']").prop("checked",true);
原文地址:https://blog.csdn.net/banjing_1993/article/details/81668646