JSFiddle - React, Tailwind, and code Playground

by Gabriele Petrioli

HTML

<input type = "checkbox"  id = "check" />
<input type = "button"  id = "buttonId" value="toggle checkbox" />

JavaScript

$("#buttonId").click( function() {
    var checkbox = $("#check")[0];

    checkbox.checked = !checkbox.checked; // invert its checked status

});