Easy Tutorial
❮ Misc Isarray Sel Hidden ❯

jQuery focusin() Method

jQuery Event Methods

Example

Set the background color of a <div> element when it or any of its child elements gain focus:


Definition and Usage

The focusin event occurs when an element (or any element inside it) gains focus.

The focusin() method adds a function to run when a focus event occurs on the element or any element inside it.

Unlike the focus() method, the focusin() method triggers even if any child element gains focus.

Tip: An element gains focus when selected by a mouse click or by tabbing through the keyboard.

Tip: This method is often used together with the focusout() method.


Syntax

Parameter Description
function Required. Specifies the function to run when the focusin event occurs.

jQuery Event Methods

❮ Misc Isarray Sel Hidden ❯