Home > Web Front-end > JS Tutorial > How to find elements by text with jQuery

How to find elements by text with jQuery

藏色散人
Release: 2020-11-30 16:31:16
Original
3154 people have browsed it

jQuery can find elements in text through the ":contains()" selector. Its syntax is "$(":contains(text)")", and the parameter text refers to the text to be found.

How to find elements by text with jQuery

The operating environment of this tutorial: windows10 system, jquery2.2.4, this article is applicable to all brands of computers.

Recommended: "jquery video tutorial"

jQuery finds elements through text

jQuery can use:contains() selection to find the element by looking for its text content.

:contains() selector selects elements that contain the specified string.

The string can be text contained directly in the element, or contained in a child element.

The most common usage: used with other selectors to select elements that contain specified text in a specified combination (such as the example above).

Note: Text is case-sensitive.

Syntax:

$(":contains(text)")
Copy after login

Parameter text is required and specifies the text to be found.

The above is the detailed content of How to find elements by text with jQuery. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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