How to force to lose focus of all fields in a form in jQuery
You can use this : $(‘:focus’).blur() If you don’t have jQuery in your site, you can replace it by : let el = document.querySelector( ‘:focus’ ); if( el ) el.blur();
You can use this : $(‘:focus’).blur() If you don’t have jQuery in your site, you can replace it by : let el = document.querySelector( ‘:focus’ ); if( el ) el.blur();
Short answer: add tabindex=”0″ attribute to an element that should appear in event.relatedTarget. Explanation: event.relatedTarget contains an element that gained focus. And the problem is that your specific div can’t gain a focus because browser thinks that this element is not a button/field or some kind of a control element. Here are the elements that … Read more