Joe Joe - 1 year ago 211
jQuery Question

jQuery lose focus event

I'm trying to show up a container if a input field gets the focus and - that's the actual problem - hide the container if focus is lost. Is there an opposite event for jQuery's focus?

Some example code:

<input type="text" value="" name="filter" id="filter"/>

<div id="options">some cool options</div>

<script type="text/javascript">

$('#filter').focus(function() {

And what I'd like to do is something like this:

$('#filter').focus_lost(function() {

Answer Source

Use blur event to call your function when element loses focus :

$('#filter').blur(function() {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download