JSFiddle - React, Tailwind, and code Playground
HTML
<div id="box">
<input type="checkbox" />
</div>
CSS
.shift-input { margin-left: 100px; }
JavaScript
$('#box').on('change', 'input', function() {
var $me = $(this);
if (this.checked) {
// Item has been checked, do nothing
}
else {
// Item has been unchecked
// Make sure it was not an accident
var confirmReset = confirm("Reset checkbox?");
if (confirmReset == true) {
// Okay, reset
}
else {
// Mistake, mark as checked again
$me.attr('checked', 'checked');
$me.addClass('shift-input');
}
}
});