jQuery Form How to - Handle focus lost event








Question

We would like to know how to handle focus lost event.

Answer


<!-- w ww  .java2 s .co  m-->
<html>
  <head>
    <script type="text/javascript" src='http://code.jquery.com/jquery-1.5.2.js'></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $("input").blur(function () {
                console.log("Hello World!");
            });
        });
    </script>
  </head>
  <body>
    <body>
     <p><input type="text" /> <span>focus event fire</span></p>
    </body>
</html>

The code above is rendered as follows: