1、全选反选
$('#choose_all_ids').click(function(){
if ($(this).prop("checked")) { // 全选
$("input[name='check_more']").each(function () {
$(this).prop("checked", true);
});
}
else { // 取消全选
$("input[name='check_more']").each(function () {
$(this).prop("checked", false);
});
}
});
// 选取节点 方法
$("input[name='check_more']")
// 多选框的属性选择
$(this).prop("checked")
2、批量删除
$('.check_apply').click(function(){
var status = $(this).attr('status');
var _all = $('#choose_all_ids');
var ids = '';
// alert(_all.prop("checked"))
$("input[name='check_more']:checked").each(function () {
var id = $(this).val(); //获取选中的ID
ids = ids + id + ',';
})
ids = ids.substr(0, ids.length-1);
if (ids != '') {
if(confirm('确定要执行此操作吗?')) {
var url = "{{ route('voyager.'.$dataType->slug.'.batch', " + ids +") }}";
// alert(url)
$.get(url, {state:status, ids:ids}, function(data){
// alert(data.code)
if (data.res === 1) {
// alert('操作成功')
if (status == 1) {
$("input[name='check_more']:checked").parents('td').siblings('.status').html('已审核');
} else {
$("input[name='check_more']:checked").parents('td').siblings('.status').html('已拒绝');
}
// window.location.reload();
} else {
alert(data.msg);
}
})
}
}
});