js 全选、反选、批删

$(function(){
        //全选反选
        $("#checkAll").click(function(){
            var ids=document.getElementsByName("id[]")
            // alert($(ids).attr("checked"));
            $(ids).each(function(){
                if($(this).attr("checked")!="checked"){
                    $(this).attr("checked",true)
                }else{
                    $(this).attr("checked",false)
                }    
            })    
        })
        //全不选
        $("#checkNoAll").click(function(){
            var ids=document.getElementsByName("id[]")
            // alert($(ids).attr("checked"));
            $(ids).each(function(){
               $(this).attr("checked",false)        
            })    

        })

function checkAll(){
    $('input:checkbox').each(function() {
        $(this).prop('checked', true);
    });
}

function queXiao(){
    $('input:checkbox').each(function () {
        $(this).prop('checked',false);
    });
}

   

    //批量删除

        $("#delAll").click(function(){
            //获取批量删除值
            var ids=$("input:checked");
            var idss="";
            $(ids).each(function(){
                   idss+=$(this).val()+',';
             });
             // alert(idss)
            $.get("{url:/test/del}",{"ids":idss},function(msg){
                if(msg){
                  $(ids).each(function(){
                       $(this).parents("tr").remove()
                  });
                  alert("删除成功!")
                }else{
                  alert("删除失败!")
                }
            })        
        })
        //几点技改
        $(document).on("click",".price",function(){
            var id=$(this).parent().attr("id");
            var val=$(this).html();
            // $(this).hide();
            $(this).parent().html("<input size='5' class='upda' value='"+val+"'>")
            $(".upda").blur(function(){
            var va=$(this).val();
            var _this=$(this);
                 $.get("{url:test/upda}",{"id":id,"price":va},function(msg){
                     if(msg){
                         _this.parent().html("<span class='price'>"+va+"</span>")
                         // console.log(t.html())
                         _this.remove();
                         alert("修改成功!")
                     }else{
                         alert("修改失败!")
                     }
                  })
            })
        })
        
        
        
    })
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值