JSFiddle - React, Tailwind, and code Playground

HTML

<form id='checkboxes'>
    <p><label>Peanuts? <input id='peanuts' type='checkbox'/></label></p>
    <p><label>Applejacks? <input id='applejacks' type='checkbox'/></label></p>
</form>

JavaScript

var checkboxes = {};

$("#checkboxes").delegate("input[type='checkbox']", 'change', function() {
    var $this = $(this);
    var id = $this.id;
    //console.log($this.prop('checked'));
    if ($this.prop('checked')) {
        checkboxes[this.id] = $this.val();
    } else {
        delete checkboxes[this.id];
    }
    console.log(id);
});