📅  最后修改于: 2022-03-11 14:57:33.955000             🧑  作者: Mango
$(document).on('click', 'input[type="checkbox"][data-group]', function(event) {
// The checkbox that was clicked
var actor = $(this);
// The status of that checkbox
var checked = actor.prop('checked');
// The group that checkbox is in
var group = actor.data('group');
// All checkboxes of that group
var checkboxes = $('input[type="checkbox"][data-group="' + group + '"]');
// All checkboxes excluding the one that was clicked
var otherCheckboxes = checkboxes.not(actor);
// Check those checkboxes
otherCheckboxes.prop('checked', checked);
});