Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove focus from input field in jQuery?

Tags:

html

jquery

focus

People also ask

How do you remove focus from field?

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.

Which event is used to lose its focus in jQuery?

jQuery focusout() MethodThe focusout event occurs when an element (or any elements inside it) loses focus. The focusout() method attaches a function to run when a focusout event occurs on the element, or any elements inside it.

How can input focus in jQuery?

Using jQuery With jQuery, you can use the . focus() method to trigger the “focus” JavaScript event on an element. This method is a shortcut for . trigger("focus") method.


Use .blur().

The blur event is sent to an element when it loses focus. Originally, this event was only applicable to form elements, such as <input>. In recent browsers, the domain of the event has been extended to include all element types. An element can lose focus via keyboard commands, such as the Tab key, or by mouse clicks elsewhere on the page.

$("#myInputID").blur(); 

check up blur():

$('#textarea').blur()

source: http://api.jquery.com/blur/