jquery复选框的多选

yongyonglsy 2017-10-09

<head>  
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>  
<script type="text/javascript">  
function selectGroup(checkbox,obj) {
 $('input[name='+obj+']').attr('checked', $(checkbox).attr('checked')); 
}  
</script>  
</head>  
<body>  
<input type="checkbox" onclick="selectGroup(this,'grp1');" />选中GROUPA<br/>  
GROUPA:<br/>
<input type="checkbox" name="grp1" />11<br/>  
<input type="checkbox" name="grp1" />22<br/>  
<input type="checkbox" name="grp1" />33<br/><br/> 
<input type="checkbox" onclick="selectGroup(this,'grp2');" />选中GROUPB<br/> 
GROUPB:<br/>
<input type="checkbox" name="grp2" />44<br/>  
<input type="checkbox" name="grp2" />55<br/>  
<input type="checkbox" name="grp2" />66<br/>  
</body>  
</html>

相关推荐

Web全栈笔记 / 0评论 2020-06-15