JSFiddle - React, Tailwind, and code Playground

HTML

<input type="checkbox" class="cb">
<input type="checkbox" class="cb">
<input type="checkbox" class="cb" checked="checked">

JavaScript

$(document).ready(function() {
      $('.cb').change(function(){
        if ($(this).is(':checked')) {
            alert('changed to checked -> uncheck again');
            $(this).attr('checked', false);
        } else {
            alert('changed to unchecked -> recheck');
            $(this).attr('checked', true);
        }
       });
    });