购物车的全选复选和不选















js

 var btn = document.getElementsByTagName("button");
    // console.log(btn);
    var inp = document.getElementsByTagName("input");
    btn[0].onclick = function(){
          for(var i=0;i<=inp.length;i++){
              // alert(111);
            inp[i].checked = true;
          }
    };
    btn[1].onclick = function(){
        for(var j = 0;j<=inp.length;j++){
            inp[j].checked = false;
        }
    };
    btn[2].onclick = function () {
        for(var i=0;i<=inp.length;i++){
            if(inp[i].checked == true){
                inp[i].checked = false;
            }else {
                inp[i].checked = true;
            }
        }
    }

你可能感兴趣的:(购物车的全选复选和不选)