Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery :contains() Selector

jQuery :contains() Selector

jQuery selector jQuery selector

Example

Select all elements containing "is"

element:

$("p:contains(is)")

Try it »


Definition and Usage

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

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

Most common usage: used together with other selectors to select elements in a specified group that contain the specified text (as in the example above).

**Note:** The text is case-sensitive.


Syntax

$(":contains(

text

)")

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

jQuery selector jQuery selector