你的话好绕,
比如你的全选复选框的id是chkAll,其它的单选框包含在id为myDiv的div里面那么以下代码来实现
$('#chkAll').click(function(){
if($(this).attr('checked')){
//选中了全选,下面的全勾中
$('#myDiv').find('checkbox').attr('checked',true);
}else{
$('#myDiv').find('checkbox').attr('checked',false);
}
});
$('#myDiv').find('checkbox').change(function(){
if($('#myDiv').find('checkbox').not("input:checked").size() <= 0){
//如果其它的复选框全部被勾选了,那么全选勾中
$('#chkAll').attr('checked',true);
}else{
$('#chkAll').attr('checked',false);
}
});