JSFiddle - React, Tailwind, and code Playground

HTML

<input type="checkbox" id="1"> <label>First</label><br>
<input type="checkbox" id="2"> <label>Second</label><br>
<input type="checkbox" id="3"> <label>Third</label><br>
<input type="checkbox" id="4"> <label>Forth</label>

JavaScript

$("input:checkbox").change(function() {
    var someObj = {};
    someObj.showid = [];
    $("input:checkbox").each(function() {
        if ($(this).is(":checked")) {
            someObj.showid.push($(this).attr("id"));
        }
    });
    alert(someObj.showid);
});