JSFiddle - React, Tailwind, and code Playground

by gromer

HTML

<label for="checkbox">Click</label>&nbsp;&nbsp;<input type="checkbox" id="checkbox" />

JavaScript

var isRequestRunning = false;
$('#checkbox').change(function(e) {
    console.log('Change event');
    
    if (isRequestRunning) {
        console.log('Running already...');
        return;
    }

    isRequestRunning = true;
    window.setTimeout(test, 5000);
});

function test() {
    $('#checkbox').prop('checked', !$('#checkbox').prop('checked'));

    isRequestRunning = false;
    console.log('Back');
}