From jQuery JavaScript Library
« Back to Events
focus( )
Triggers the focus event of each matched element.
This causes all of the functions that have been bound to the focus event to be executed. Note that this does not execute the focus method of the underlying elements.
Examples:| Name | Type |
To focus on a login input box with id 'login' on page startup, try:
$(document).ready(function(){
$("#login").focus();
});
focus( fn )
Binds a function to the focus event of each matched element.
The focus event fires when an element receives focus either via the pointing device or by tab navigation.
Arguments:| fn | Function | |
|---|
A function to bind to the focus event on each of the matched elements.
function callback(eventObject) {
this; // dom element
}
|
Examples:| Name | Type |
To stop people from writing in text input boxes, try:
$("input[@type=text]").focus(function(){
$(this).blur();
});