jQuery :contains() Selector (original) (raw)

Last Updated : 11 Jul, 2025

The jQuery :contains() selector in jQuery is used to select elements containing the specified string.

Syntax:

$(":contains(text)")

Parameters: This selector contains single parameter text which is mandatory and used to specify the text to find.

Example 1: This example uses :contains() selector to select an element.

HTML `

jQuery :contains() Selector

GeeksForGeeks

jQuery :contains() Selector

Who is your favourite Geek:

Geek 1

Geek 2

Geek 3

`

Output:

Example 2: This example use :contains() selector to select an element.

HTML `

jQuery :contains() Selector

GeeksForGeeks

jQuery :contains() Selector

Who is your favourite candidate:

Geek 1

Geek 2

Geek 3

`

Output: