js
$(function () {
var $choose = $("#choose input");
$("#all").click(function () {
$choose.each(function () {
$(this).prop("checked", true);
});
});
$("#not").click(function () {
$choose.prop("checked", false);
});
$("#reverse").click(function () {
$choose.each(function () {
$(this).prop("checked", !$(this).prop("checked"));
});
});
$("#alldel").click(function () {
var f = false;
var arr = [];
var ck = document.getElementsByName("spu_id");
for (var i = 0; i < ck.length; i++) {
if (ck[i].checked == true) {
arr.push(ck[i].value);
f = true;
}
}
if (f == true) {
if (confirm("您确认要全部下架吗?"))
{
alert(arr);
}
} else {
alert("请至少选中一条进行批量删除");
}
})
});
html
<input id="all" type="button" value="全选" />
<input id="not" type="button" value="全不选" />
<input id="reverse" type="button" value="反选" />
<input id="alldel" type="button" value="批量上架" />