.focusout()

.focusout( handler(eventObject) ) Returns: jQuery

Description: Bind an event handler to the "focusout" JavaScript event.

  • version added: 1.4.focusout( handler(eventObject) )

    handler(eventObject)A function to execute each time the event is triggered.

This method is a shortcut for .bind('focusout', handler).

The focusout event is sent to an element when it, or any element inside of it, loses focus. This is distinct from the blur event in that it supports detecting the loss of focus from parent elements (in other words, it supports events bubbling).

This event will likely be used together with the focusin event.

Example:

Watch for a loss of focus to occur within the paragraphs on the page.

<!DOCTYPE html>
<html>
<head>
  <style>span {display:none;}</style>
  <script src="https://code.jquery.com/jquery-latest.js"></script>
</head>
<body>

<p>
  <input type="text" />
  <span>focusout fire</span>
</p>
<p>
  <input type="password" />
  <span>focusout fire</span>
</p>
<script>
$("p").focusout(function() {
  $(this).find("span").css('display','inline').fadeOut(1000);
});
    </script>
</body>
</html>

Demo: