JSFiddle - React, Tailwind, and code Playground
HTML
<a href="#" id="test">Test link</a>
<br>
<label><input type="checkbox">Override other handlers</label>
JavaScript
var overrideClick = false;
$("#test").click(function(e) {
if (overrideClick) {
e.stopImmediatePropagation();
// e.preventDefault(); uncomment this if you want to prevent default action too
}
});
$("#test").click(function() {
alert("Click handler 1");
});
$("body").on("click", "a", function() {
alert("Delegated click handler");
});
$("input").click(function() {
overrideClick = this.checked;
});