jQuery :contains Selector

Example

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

$("p:contains(is)")

Try It Yourself

Definition and Usage

:contains selector selects elements that contain the specified string.

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

Often used with other elements/selectors to select elements that contain specified text in the specified group (as shown in the above example).

Syntax

$(':contains(')text)")
Parameter Description
text Required. Specifies the text to be searched for.