<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="./jquery使用/jquery.js"></script>
</head>
<script>
$(function(){
/* 全选全不选 */
$(".checkall").change(function(){
$(".checkall,.j-checkbox").prop("checked",$(this).prop("checked"))
});
/* :checked选择个数 */
$(".j-checkbox").change(function(){
if($(".j-checkbox:checked").length===$(".j-checkbox").length){
$(".checkall").prop("checked",true);
}else{
$(".checkall").prop("checked",false);
}
})
})
</script>
<body>
<div class="t-checkbox">
<input type="checkbox" class="checkall">全选
</div>
<div class="item">
<div class="p-checkbox">
<input type="checkbox" class="j-checkbox" checked>复选
<input type="checkbox" class="j-checkbox">复选
<input type="checkbox" class="j-checkbox">复选
<input type="checkbox" class="j-checkbox">复选
</div>
</div>
<div class="t-checkbox">
<input type="checkbox" class="checkall">全选
</div>
</body>
</html>