JSFiddle - React, Tailwind, and code Playground

HTML

<input type="checkbox" id="chk" value="value" />
<label for="chk">Value </label>
<br/>
<input type="button" id="But1" value="set value" />
<br />
<input type="button" id="But2" value="read checked" />

CSS

.selected { background:red; }

JavaScript

$('input:checkbox').change(function () {
            var name = $(this).val();
            var check = $(this).attr('checked');
            console.log("Change: " + name + " to " + check);
        });