Home >Web Front-end >JS Tutorial >Detailed explanation of the use of jquery :focus selector
Overview
Trigger the focus event of each matching element.
This will trigger all bound focus functions. Note that some objects do not support the focus method.
Example
Description:
Set focus to the element with id 'login' after the page loads:
jQuery code:
$("#login:focus");
This selector can match the currently focused element.
Syntax structure:
$("li:focus")
:The focus selector generally needs to be used in conjunction with other selectors, such as class selector, element selector etc. For example:
$("li:focus")
The above code will match the li element that has received focus.
Of course, no other selector is added in front of this selector, but if the specified selector is not added, then the universal selector (*) is added by default. For example:
$(":focus")
The above code is equivalent to the following code:
$("*:focus")
Example code:
脚本之家
The above is the detailed content of Detailed explanation of the use of jquery :focus selector. For more information, please follow other related articles on the PHP Chinese website!