Home >Web Front-end >JS Tutorial >Detailed explanation of the use of jquery :focus selector

Detailed explanation of the use of jquery :focus selector

黄舟
黄舟Original
2017-06-23 10:56:412176browse

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:






脚本之家




  • div+css专区
  • HTML专区

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!

Statement:
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