How to force to lose focus of all fields in a form in jQuery

You don't need jQuery for this; vanillaJS can do this, too.

document.activeElement.blur();

Note: Usually, I would check for null-ness before calling a method, but activeElement will only ever return null if there is no ‹body› node, so this direct call is pretty safe.


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();