to disable the click event on any element that you want. To disable the click event on an element, we can use the pointer-events property. In the right panel only click the button; Notice numbers are going up for the focus and blur event on the window as well; Expected behavior Number should only increase for button clicks. HTML Tag Reference HTML Browser Support HTML Event Reference HTML Color Reference HTML Attribute Reference HTML Canvas Reference HTML SVG Reference Google Maps . If you want to handle the event in the capture phase instead of the bubbling phase, you just add 'Capture' to the end of the event handler name: <button onClickCapture= { (e) => console.log ('Fires before bubbling', e)} />. Logic seems that e.preventDefault() on the blur event for that cell should keep the focus there, but it does not. I'm using MAC 10.6 and FF 3.5. When focus is triggered and the link is clicked, blur is also triggered. Syntax: $(selector).blur(function) Parameter: It accepts an optional parameter "function". . Since the click event fires after the blur, there is no (cross-browser, reliable) way to tell what element is gaining focus. Listen to a blur event on the parent element (in my case it was the menu). But notice the behavior. Simply set the pointer-events property to. version added: 1.0 event.preventDefault () This method does not accept any arguments. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more. Problem is button click gets ignored because the blur event fires first and brings the spinner on the screen while its making server call to save data. It is fully supported in all . Returning false just doesn't make sense. If it is, do nothing, as focus hasn't exited the parent yet. Examples Simple example HTML <form id="form"> <input type="text" placeholder="text input"> <input type="password" placeholder="password"> </form> So you can use it to cancel the blur. Technologies Used Find the technologies being used in our example. Service call while onBlur event Input blur template-driven form validation. We can use event.isDefaultPrevented () to determine if this method has been called by an event handler that was triggered by this event. .
How to detect a click event on a cross domain iframe · GitHub Example 1: app.component.ts. Please note that we can't "prevent losing focus" by calling event.preventDefault () in onblur, because onblur works after the element lost the focus. In the handler, give browser time to focus the next element (by using requestAnimationFrame ).