首页 > 代码库 > 全选反选

全选反选

function All(){
          var checkeds = document.getElementsByName("id[]");
          for(i = 0; i < checkeds.length; i++){
               checkeds[i].checked = true;
          }
     }
     function antiAll(){
          var selects = document.getElementsByName("id[]");
          for(i = 0; i < selects.length; i++){
               if(selects[i].checked == true){
                    selects[i].checked = false;
               }
               else{
                    selects[i].checked = true;
               }
          }
     }

全选反选