JSFiddle - React, Tailwind, and code Playground
HTML
<label for="mycheckbox">Click to fire</label> <input type="checkbox" id="mycheckbox" value="1" name="mycheckbox" />
<br />
<span id="output"></span>
JavaScript
$(document).ready(function() {
// global counter to track triggers
window.count = 0;
// on change, increment counter and output html
$('#mycheckbox').change(function() {
window.count++;
jQuery('#output').html('I fired: ' + window.count + ' times<br />');
});
// programmatically fire a click event
// this should also trigger the change event above
// IE7/8 don't trigger .change() but all others do
$('#mycheckbox').click();
});