Home > Web Front-end > JS Tutorial > body text

Detailed explanation of the use of jquery :focus selector

黄舟
Release: 2017-06-23 10:56:41
Original
2171 people have browsed it

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");
Copy after login

This selector can match the currently focused element.

Syntax structure:

$("li:focus")
Copy after login
Copy after login

:The focus selector generally needs to be used in conjunction with other selectors, such as class selector, element selector etc. For example:

$("li:focus")
Copy after login
Copy after login

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")
Copy after login

The above code is equivalent to the following code:

$("*:focus")
Copy after login

Example code:






脚本之家




  • div+css专区
  • HTML专区
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template