JSFiddle - React, Tailwind, and code Playground

HTML

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/dot-luv/jquery-ui.css">
<input type="checkbox" id="someID" />

<input type="checkbox" id="someOtherID" />

<input type="checkbox" id="anotherID" />

<input type="hidden" id="chk_count" />

JavaScript

$('input:checkbox').click(function() {

    var theID = $(this).attr('id');  // Grab the ID of the checkbox

    var $hidden = $('#chk_count');
    
    if(!$hidden.val()) {        // Increment the hidden field
        $hidden.val(1);
    } else {
        $hidden.val( parseInt($hidden.val()) + 1 );
    }
    
    alert('theID: ' + theID + '\n\nthe count: ' + $hidden.val());
});