JSFiddle - React, Tailwind, and code Playground
HTML
<input type="checkbox" class="checkbox" />
<input type="checkbox" class="checkbox" />
<input type="checkbox" class="checkbox" />
<input type="checkbox" class="checkbox" />
<br>
<button>Toggle</button>
JavaScript
function toggleChecked() {
var boxes = $(".checkbox");
boxes.each(function(){$(this).prop("checked", !$(this).prop("checked"));});
}
$('button').click(toggleChecked);