using Jquery/javascript
Is it: $(document).focus()?
Events focus/blur The focus event is called on focusing, and blur – when the element loses the focus. Let's use them for validation of an input field. In the example below: The blur handler checks if the field has an email entered, and if not – shows an error.
blur() method removes keyboard focus from the current element.
The blur event fires when an element has lost focus. The main difference between this event and focusout is that focusout bubbles while blur does not. The opposite of blur is focus . This event is not cancelable and does not bubble.
Use the blur() method to remove the focus from an element, e.g. input. blur() . If you need to remove the focus from the currently active element without selecting it, call the blur method on the activeElement property - document.
The .focus()
method on a jQuery-wrapped element will bind to the onfocus
event if a function is passed as the first parameter, or trigger attached event handlers with no parameter.
I'm not sure why you're trying to do what you're trying to do, but if you're trying to blur the currently active element, no matter what element it is, you can use:
if ("activeElement" in document) document.activeElement.blur();
This isn't advised though, as doing so will reset the tabbing order and potentially annoy keyboard-navigating users.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With