<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="js/jquery3.6.0.js"></script>
</head>
<body>
<table>
,<thead>
<tr>
<th><input type="checkbox"></th>
<th>姓名</th>
<th>年龄</th>
<th>爱好</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="checkbox"></td>
<td>诸葛亮</td>
<td>80</td>
<td>喂猪</td>
</tr>
<tr>
<td><input type="checkbox"></td>
<td>刘备</td>
<td>62</td>
<td>入洞房</td>
</tr>
<tr>
<td><input type="checkbox"></td>
<td>吕布</td>
<td>38</td>
<td>杀人</td>
</tr>
</tbody>
</table>
<script>
$('thread input').change(function(){
var isChecked=$(this).prop("checked")
$('tbody input').prop("checked",isChecked);
})
$('tbody input').change(function(){
var allCount= $('tbody input').length;
var checkCount=$('tbody input:checked').length;
var isAllChecked=allCount===checkCount;
$('thead input').prop('check',isAllChecked);
})
</script>
</body>
</html>