jQeury 批量删除

/*批量删除*/
function datadel(){
    var ids = new Array();
    $("input[name='batch']:checked").each(function(){
        ids.push($(this).val());
    });
    if(ids.length == 0){
        layer.alert('请选择要删除的数据!');
    }else{
        ids = ids.join(',');
        layer.confirm('确认要删除吗?',function(index){
            $.ajax({
                type: 'POST',
                url: 'batchDel',
                data: {ids: ids},
                dataType: 'json',
                success: function(data){
                    $("input[name='batch']:checked").each(function(){
                        $(this).parents("tr").remove();
                    });
                    
                    layer.msg(data.info, {icon:1,time:1000});

                },
                error:function(data) {
                    console.log(data.msg);
                },
            });        
        });

    }
}

 

posted on 2018-07-04 17:03  Ben丶大壮  阅读(79)  评论(0编辑  收藏  举报

导航