jQuery :contains()Selector

jQuery 选择器jQuery Selectors

Examples

Select all <p> elements that contain "is":

$("p:contains(is)")

Try it Yourself »

Definition and Usage

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

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

The most common usage: combine it with other selectors to select elements containing the specified text in a specified combination (like the example above).

Note:The text is case-sensitive.


Syntax

$(":contains(text)")

Parameter Description
text Required. Specifies the text to search for.


jQuery 选择器jQuery Selectors

Other Extensions