JSFiddle - React, Tailwind, and code Playground
HTML
<button>Test</button>
JavaScript
$("button").click(function (event) {
$("body").trigger("some-custom-event");
// If the custom event was prevented, prevent original one too
if (true) { // How to check?
event.preventDefault();
}
})
$("body").on("some-custom-event", function (event) {
if (Math.random() > .5) {
console.log("prevent");
event.preventDefault();
} else {
console.log("allow");
}
})