jquery 對asp.net CheckBoxList全選、反選

第一種:

全選
    $(".checkBoxSelect").each(function() { 
                $(this).attr("checked", true);  
     });
反選
     $(".checkBoxSelect").each(function() { 
                        if($(this).attr("checked")) 
                        { 
                                $(this).attr("checked", false); 
                        } 
                        else 
                        { 
                                $(this).attr("checked", true); 
                        } 
                });
 
第二種
 
全選
    $("#<%=CheckBoxList.ClientID %> input:checkbox").each(function(index,domEle){ 
              if(this.type=="checkbox")
                   this.checked=true;
    });反選 
    $("#<%=CheckBoxList.ClientID %> input:checkbox").each(function(index,domEle){ 
             if(this.type=="checkbox")
                  this.checked=!this.checked;
    });
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章