JSFiddle - React, Tailwind, and code Playground

HTML

<input type="checkbox" id="chk" value="value" name="test" />
<label for="chk">Value </label>
<br/>
<input type="button" id="badBut1" value="change value (not working)" />
<br />
<input type="button" id="But1" value="change value (working)" />
<br />
<input type="button" id="But2" value="read checked" />

JavaScript

$('#badBut1').click(function () {
            checkit('Before');
            if( $('#chk').prop('checked') )
            {
          	  $('#chk').removeProp('checked');
            }else{
        	    $('#chk').prop('checked', true);
            }
            checkit('After');
        });
        $('#But1').click(function () {
            checkit('Before');
            if( $('#chk').prop('checked') )
            {
          	  $('#chk').removeClass('checked').prop('checked',false);
            }else{
        	    $('#chk').addClass('checked').prop('checked', true);
            }
            checkit('After');
        });
        
        $('#But2').click(function () {
            var chk1 = $('#chk').is(':checked');
            console.log("Value : " + chk1);
        });

        $('#chk').on( 'change',function () {
            checkit('Result');
        });
        function checkit(moment) {
            var chk1 = $('#chk').is(':checked');
            console.log(moment+", value = " + chk1);
        };