jquery实现复选框打勾全选,其中一个子复选框不勾中,则不全选。所有子复选框全勾中则又全选。
$('#allSelect').click(function() {
if($(this).attr('checked')){
$("input[name='videoId']").attr("checked","true");
}else{
$("input[name='videoId']").removeAttr("checked");
}
});
$("input[name='videoId']").change(function(){
if($("input[name='videoId']").not("input:checked").size() <= 0){
//如果其它的复选框全部被勾选了,那么全选勾中
$('#allSelect').attr('checked',true);
}else{
$('#allSelect').attr('checked',false);
}
});