JSFiddle - React, Tailwind, and code Playground
HTML
<div id="capture">
<button id="test_capture">Test capture click event</button>
</div>
JavaScript
$("#test_capture").mouseup(function (e) {
alert('mouseup');
var captureClick = function(e) {
alert('click captured');
e.stopPropagation();
this.removeEventListener('click', captureClick, true); // cleanup
}
$('#capture')[0].addEventListener(
'click',
captureClick,
true // <-- This registeres this listener for the capture phase instead of the bubbling phase
);
});
$("#test_capture").click(function (e) {
alert('click');
});