Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deselect/Unfocus input field using JQuery [duplicate]

Possible Duplicate:
Jquery Unfocus

Is there a way to deselect/unfocus an input field using JQuery? Something like $("input#name").select().focus(); but in reverse?

like image 330
Ryan Brodie Avatar asked Sep 10 '25 16:09

Ryan Brodie


2 Answers

.blur();

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

Bind an event handler to the "blur" JavaScript event, or trigger that event on an element.

...This method is a shortcut for... .trigger( "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...

like image 81
isotrope Avatar answered Sep 12 '25 08:09

isotrope


You can use the blur method from jQuery API

So it would be:

$('input').blur();

Hope it was useful !

like image 30
macpie Avatar answered Sep 12 '25 07:09

macpie