jQuery focusin() Method

jQuery focusin() method trigger the focusin event. The jQuery focusin event occurs when an element (or any elements inside it) gets focus. And when the focusin event occurs, specified function will execute.

jQuery focus() method trigger on the selected element. Where as jQuery focusin() method trigger on the selected element including any child elements inside it.


This triggers the focusin event for selected elements or any child elements inside it.

$(selector).focusin();        // This syntax does not accept any arguments.

This attach a function to the focusin event.

Parameter Type Description
function Function Optional. Specifies the function to execute when the focusin event is occurs.


This example represents the focusin() event.

<!DOCTYPE html>
  <title>jQuery focusin() and focusout() method</title>
  <script src="jquery-latest.min.js"></script>
        $(this).css("background-color", "yellow");
        $(this).css("background-color", "white");
  <p>Click on following text field to occur focusin or focusout events.</p> 
  <div style="padding:15px 10px;">
    Name: <input type="text" name="name" />
  <div style="padding:15px 10px;">
    E-mail: <input type="text" name="email" />
  <div style="padding:15px 10px;">
    Phone: <input type="text" name="phone" />

Run it...   »