jQuery focusin()Method
Example
When a <div> element or any of its child elements gains focus, set the background color of the <div> element:
$("div").focusin(function(){
$(this).css("background-color","#FFFFCC");
});
$(this).css("background-color","#FFFFCC");
});
Try it Yourself »
Definition and Usage
The focusin event occurs when an element (or any element inside it) gains focus.
The focusin() method attaches a function to run when a focus event occurs on the element, or on any element inside it.
andfocus()Unlike the focus() method, the focusin() method also triggers when any child element gains focus.
Tip:An element gains focus when it is selected by a mouse click or navigated to via the Tab key.
Tip:This method is usually used together withfocusout()the method.
Syntax
$(selector).focusin(function)
| Parameter | Description |
|---|---|
| function | Required. Specifies the function to run when the focusin event occurs. |
Other Extensions
jQuery Event Methods