// 全选 反选
allChoose: function (o) {
var obj = $.extend(true, {
id: "#id",
name: "name",
allSelection: true,
invertSelection: true
}, o);
var $id;
if (obj.id.substring(1) === "#") {
$id = obj.id;
} else {
$id = "#" + obj.id;
}
if (obj.invertSelection) {
// 全选
$($id).on("click", function () {
var checked = $(this).is(":checked");
$("input[name='" + obj.name + "']").prop("checked", checked);
});
}
if (obj.invertSelection) {
// 反选
$("input[name='" + obj.name + "']").on("click", function () {
var count = $("input[name='" + obj.name + "']").size();
var checkedCount = $("input[name='" + obj.name + "']:checked").size();
if (count === checkedCount) {
$($id).prop("checked", "checked");
} else {
$($id).removeProp("checked");
}
});
}
}