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);}}});
 });
posted on 2009-07-23 17:06  ToKens  阅读(202)  评论(0编辑  收藏  举报