- <script type="text/javascript">
- $(function() {
- $("#selectall").click(function() {
- $("input[@name='shareuser[]']").each(function() {
- $(this).attr("checked", true);
- });
- });
- $("#deselectall").click(function() {
- $("input[@name='shareuser[]']").each(function() {
- $(this).attr("checked", false);
- });
- });
- });
- </script>
- <input type='checkbox' id='in-shareuser-10' name='shareuser[]' value='10' />UserA
- <input type='checkbox' id='in-shareuser-11' name='shareuser[]' value='11' />UserB
- <input type='checkbox' id='in-shareuser-12' name='shareuser[]' value='12' />UserC
- <input type="button" id="selectall" name="selectall" value="全选" />
- <input type="button" id="deselectall" name="deselectall" value="取消全选" />
jQuery全选
最新推荐文章于 2022-12-28 19:58:46 发布
本文介绍了一个使用jQuery实现的批量选择与取消选择用户的脚本。该脚本通过两个按钮控制一组复选框的状态,实现了全选与取消全选的功能。适用于网站后台管理等场景。
646

被折叠的 条评论
为什么被折叠?



