jQuery代码实现全选反选功能
<title>全/全不选,反选</title>
<script type="text/javascript" src="js/jquery-1.8.2.js"></script>
<script type="text/javascript">
function qx() {
if($(":checkbox").attr("checked")){
$(":checkbox").attr("checked",false);
}else{
$(":checkbox").attr("checked",true);
}
}
function fx() {
$(":checkbox").each(function() {
$(this).attr("checked",!$(this).attr("checked"));
}
</script>
</head>
<body>
<input type="checkbox">
<input type="checkbox">
<input type="checkbox">
<input type="checkbox">
<input type="checkbox"><br>
<input type="checkbox" onclick="qx()">全/全不选
<input type="checkbox" onclick="fx()">反选
</body>
</html>