jQuery focus()Method
Example
Add a function to the focus event. The focus event occurs when the <input> field gets focus:
$("input").focus(function(){
$("span").css("display","inline").fadeOut(2000);
});
Try it yourself »
Definition and Usage
The focus event occurs when an element gets focus (when selected by a mouse click or by tab navigation).
The focus() method triggers the focus event, or specifies a function to run when the focus event occurs.
Tip:This method is usually used together with theblur()method.
Syntax
Trigger the focus event for the selected elements:
$(selector).focus()
Try it yourself
Add a function to the focus event:
$(selector).focus(function)
Try it yourself
| Parameter | Description |
|---|---|
| function | Optional. Specifies the function to run when the focus event occurs. |
Other Extensions
jQuery Event Methods