JSFiddle - React, Tailwind, and code Playground
HTML
<table>
<tr>
<td>
<input type="checkbox" name="checkAll" id="checkAll" onchange="checkAll('book[1][]')">全選 (ALL)
<input type="checkbox" name="book[1][]" id="book_1" value="book1">book1
<input type="checkbox" name="book[1][]" id="book_2" value="book2">book2
<input type="checkbox" name="book[1]" id="book_3" value="book3">book3
<input type="checkbox" name="book[2]" id="book_4" value="book4">book4
<input type="checkbox" name="book5[]" id="book_5" value="book5">book5
</td>
</tr>
</table>
JavaScript
function checkAll(id) {
$('input:checkbox[name="'+id+'"]').prop('checked', 'true');
}