JSFiddle - React, Tailwind, and code Playground

by ryanwheale

HTML

<input type="checkbox" id="my-checkbox" /><label for="my-checkbox">My Checkbox</label>
<div id="output"></div>

JavaScript

$(function() {
    var $myCheckbox = $('#my-checkbox'),
        $output = $('#output');
    
    $myCheckbox.bind('change', function() {
        $output.html($output.html() + '<br />changed: ' + $myCheckbox.attr('checked') + ', ' + $myCheckbox.prop('checked'));
    }).trigger('change');
    
    setTimeout(function() {
        $myCheckbox.prop('checked', true).trigger('change');
    
        setTimeout(function() {
            $myCheckbox.removeAttr('checked').trigger('change');
        }, 1000);
    }, 1000);
});