FocusIn Event




Set Focus to textbox to trigger, FocusIn event

Input 1:

Input 2:

Input 3:





Sourcode

    Try It Yourself
 
<html>
<head>


<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />


<script type="text/javascript" language="Javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

</head>
<body>

<h2>FocusIn Event</h2>
<hr />
<br /><br />

<b>Set FocusIn to textbox to trigger, FocusIn event</b><br />
<input id="txtInput" type="text" />

<br /><br />

<script language="javascript" type="text/javascript">
    $(document).ready(function () {

        $("#txtInput1").focusin(
            function (event) {
                $("#txtInput1").css("background-color", "Yellow");
            }
        );

        $("#txtInput2").focusin(
            function (event) {
                $("#txtInput2").css("background-color", "Red");
            }
        );

        $("#txtInput3").focusin(
            function (event) {
                $("#txtInput3").css("background-color", "Green");
            }
        );

    });
</script>

</body>
</html>
Share with your friends!!