<table class="header-table" cellspacing="0" cellpadding="0" border="0">
<thead>
<tr>
<th>
<input class="checkall" type="checkbox" >
</th>
<th class="header-box_th_2">序号</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input class="j-checkbox" type="checkbox">
</td>
<td>1</td>
</tr>
<tr>
<td>
<input class="j-checkbox" type="checkbox">
</td>
<td>2</td>
</tr>
</tbody>
</table>
$(".checkall").change(function() {
$(".j-checkbox, .checkall").prop("checked", $(this).prop("checked"));
})
$(".header-table").on('change', '.j-checkbox', function() {
if ($(".j-checkbox:checked").length === $(".j-checkbox").length) {
$(".checkall").prop("checked", true);
} else {
$(".checkall").prop("checked", false);
}
});