jquery实现复选框多选、单选、全不选功能,很实用

老虎说测试 前端技术字数 723阅读2分24秒阅读模式
摘要jquery实现复选框多选、单选、全不选功能,很实用

jquery实现复选框多选、单选、全不选功能,很实用

[php]文章源自陈学虎-https://chenxuehu.com/article/2013/06/1184.html

<html>
<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/>文章源自陈学虎-https://chenxuehu.com/article/2013/06/1184.html

<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>文章源自陈学虎-https://chenxuehu.com/article/2013/06/1184.html

[/php]文章源自陈学虎-https://chenxuehu.com/article/2013/06/1184.html 文章源自陈学虎-https://chenxuehu.com/article/2013/06/1184.html

 
  • 版权声明:本文为原创文章,转载请附上原文出处链接及本声明。
  • 转载请注明:jquery实现复选框多选、单选、全不选功能,很实用 | https://chenxuehu.com/article/2013/06/1184.html