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);
                },
            });        
        });

    }
}

猜你喜欢

转载自www.cnblogs.com/mz0104/p/9264176.html
今日推荐