1. 程式人生 > 其它 >js中checkbox分組全選

js中checkbox分組全選

技術標籤:html

<?php echo $row["bj"];?> 
  <div class="danhang"> 
    <?php

while( r o w 2 = m y s q l f e t c h a r r a y ( row2 = mysql_fetch_array( row2=mysqlfetcharray(result2)){
?>

 <label><input type="checkbox" name="recname" value="<?php echo $row2["xh"];?>" cid="a"><?php echo $row2["xm"];?></label>

<?php } ?>

</div>	

$(".all").click(function(){
var isChecked = $(this).is(":checked");
if(isChecked){
$(this).parent().parent().next().children(‘label’).children(‘input’).prop(‘checked’,true);
}else{
$(this).parent().parent().next().children(‘label’).children(‘input’).prop(‘checked’,false);
}
});