jQuery checkbox 全选,取消全选
代码有点乱,没格式化
$(function(){
$('#checkAll').bind('click',function(e){if($(e.target).attr('checked')){$(':checkbox','#GridView1 td').attr('checked',true);}else{$(':checkbox','#GridView1 td').attr('checked','');}});
$(':checkbox','#GridView1 td').bind('click',function(){if(!this.checked){$('#checkAll').attr('checked','');}else{var b=true;$(':checkbox','#GridView1 td').each(function(i,e){if(!e.checked){b=false;return;}});if(b){$('#checkAll').attr('checked',true);}}});
});
$(function(){
$('#checkAll').bind('click',function(e){if($(e.target).attr('checked')){$(':checkbox','#GridView1 td').attr('checked',true);}else{$(':checkbox','#GridView1 td').attr('checked','');}});
$(':checkbox','#GridView1 td').bind('click',function(){if(!this.checked){$('#checkAll').attr('checked','');}else{var b=true;$(':checkbox','#GridView1 td').each(function(i,e){if(!e.checked){b=false;return;}});if(b){$('#checkAll').attr('checked',true);}}});
});