Easy Tutorial
❮ Event One Jq Sel Lang ❯

jQuery focus() Method

jQuery Event Methods

Example

Add a function to the focus event. The focus event occurs when the <input> field gains focus:

$("input").focus(function(){
    $("span").css("display","inline").fadeOut(2000);
});

Definition and Usage

The focus event occurs when an element gains focus (when the element is selected by clicking on it or by tabbing to it).

The focus() method triggers the focus event, or specifies a function to run when a focus event occurs.

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


Syntax

Trigger the focus event for the selected elements:

Add a function to the focus event:

Parameter Description
function Optional. Specifies the function to run when the focus event occurs.

jQuery Event Methods

❮ Event One Jq Sel Lang ❯