Handle input focus event

Description

The following code shows how to handle input focus event.

Example


<html>
<head>
<script type="text/javascript"
  src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {<!--from   w  ww . j  a  v a2  s .c  om-->
    $("input").focus(function() {
      $(this).next("span").css('color', 'red');
    });
  });
</script>
</head>
<body>
  <p>
    <input type="text" /> <span>focus event fire</span>
  </p>
</body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Example »




Animation
DOM
Event
Form
List
Select
Style
Table
Utilities