<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="./../jquery.min.js"></script>
</head>
<body>
<input type="checkbox" class="checkall"> 全选
<hr>
<input type="checkbox" class="a-check"> 单选
<input type="checkbox" class="a-check"> 单选
<input type="checkbox" class="a-check"> 单选
<hr>
<input type="checkbox" name="" id="" class="checkall"> 全选
<script>
$(function() {
$(".checkall").change(function() {
$(".a-check, .checkall").prop("checked", $(this).prop("checked"))
})
$(".a-check").change(function() {
// 获取被选中的 小 复选框个数 :checked
if($(".a-check:checked").length == $(".a-check").length) {
$(".checkall").prop("checked", true)
} else {
$(".checkall").prop("checked", false)
}
})
})
</script>
</body>
</html>
10-23
439
06-10
100
08-16
227
05-12