Cancel click event in the mouseup event handler

Use the event capture phase Put an element around the element you want to cancel the click event for, and add a capture event handler to it. var btnElm = document.querySelector(‘button’); btnElm.addEventListener(‘mouseup’, function(e){ console.log(‘mouseup’); window.addEventListener( ‘click’, captureClick, true // <– This registeres this listener for the capture // phase instead of the bubbling phase! ); … Read more