tadam logo
Did you find an error in the text?
Select this with mouse and press
Ctrl + Enter
Xhtml.co.il Check Spelling
Orphus system

focusin()

focusin()

Returns: jQuery

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

.focusin( handler(eventObject) )

version added: 1.4
handler(eventObject)
A function to execute each time the event is triggered.

.focusin( [ eventData ], handler(eventObject) )

version added: 1.4.3
eventData
A map of data that will be passed to the event handler.
handler(eventObject)
A function to execute each time the event is triggered.

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

The focusin event is sent to an element when it, or any element inside of it, gains focus. This is distinct from the focus event in that it supports detecting the focus event on parent elements.

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

Example

Watch for a focus to occur within the paragraphs on the page.
    $("p").focusin(function() {
         $(this).find("span").css('display','inline').fadeOut(1000);
    });
The output of the code above will be:

Full source

Watch for a focus to occur within the paragraphs on the page.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
  <style>span {display:none;}</style>

<script src="http://code.jquery.com/jquery-latest.js"></script>
  
  <script type="text/javascript" language="javascript">
  $(document).ready(function(){
    $("p").focusin(function() {
         $(this).find("span").css('display','inline').fadeOut(1000);
    });
  });
  </script>

</head>

<body>
	<p><input type="text" /> <span>focusin fire</span></p>
<p><input type="password" /> <span>focusin fire</span></p>

</body>
</html>
Was this information helpful?
   

Comments