jQuery focus () method
Examples
Add the function to the focus event. focus event occurs when the <input> field receives the focus:
$("input").focus(function(){
$("span").css("display","inline").fadeOut(2000);
});
$("span").css("display","inline").fadeOut(2000);
});
try it"
Definition and Usage
When the element receives the focus (when the mouse click on the selected element or elements by targeting tab key), focus events occur.
focus () method triggers the focus event, or when a predetermined function to run when the event occurs focus.
Note: This method is usually the blur () used with the method.
grammar
Trigger the selected element focus events:
$(selector).focus()
尝试一下
Add the function to the focus event:
$(selector).focus(function)
尝试一下
参数 | 描述 |
---|---|
function | 可选。规定当 focus 事件发生时运行的函数。 |