JQuery的全选,全不选,反选!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    
<title></title>
    
<link rel="stylesheet" type="text/css" href="Css/Commom.css" />
    
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    
<script language="javascript" type="text/javascript">

        $(
function () {
            $(
"#selAll").click(function () {
                $(
".column :checkbox").attr("checked"true);
            });

            $(
"#unSelAll").click(function () {
                $(
".column :checkbox").attr("checked"false);
            });

            $(
"#reverSel").click(function () {
                
//遍历.column 下的 checkbox;
                $(".column :checkbox").each(function () {
                    
//给当前勾选的checkbox取反;  其中!$(this).attr("checked")是先获取他的属性,再取反,充当第二个参数;
                    //attr方法只有一个参数时是取值,两个参数时是设值;
                    $(this).attr("checked"!$(this).attr("checked"));
                });
            });
        });

    
</script>
</head>
<body>
    
<div class="column">
        
<input id="Checkbox1" type="checkbox" value="修改密码" />
        修改密码
        
<input id="Checkbox2" type="checkbox" value="评论管理" />
        评论管理
        
<input id="Checkbox3" type="checkbox" value="删除文章" />
        删除文章
        
<input id="Checkbox4" type="checkbox" value="删除用户" />
        删除用户
        
<input id="Checkbox5" type="checkbox" value="备份数据" />
        备份数据
    
</div>
    
<div class="column">
        
<input id="selAll" type="button" value="全选" />
        
<input id="unSelAll" type="button" value="全不选" />
        
<input id="reverSel" type="button" value="反选" />
    
</div>
</body>
</html>
原文地址:https://www.cnblogs.com/zhuiyi/p/2091738.html