Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery focusin() method

jQuery focusin() method

jQuery event methods jQuery event methods

Example

When

When the element or any of its child elements gain focus, set
elements' background color:

$("div").focusin(function(){

$(this).css("background-color","#FFFFCC");

});

Try it »


Definition and Usage

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

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

The difference between 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 located via the tab key.

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


Syntax

$(

selector

).focusin(

function

)

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

jQuery event methods jQuery event methods