Latest web development tutorials

jQuery: contains () selector

jQuery selector jQuery selector

Examples

Select all "is" the <p> element:

$("p:contains(is)")

try it"

Definition and Usage

: Contains () selector to select the element that contains the specified string.

The string can be included directly in the text element, or be included in the sub-elements.

The most common usage: used in conjunction with other selectors, select the specified combination contains specified text elements (such as the above example).

NOTE: The text is case sensitive.


grammar

$(":contains(text)")

参数 描述
text 必需。规定要查找的文本。


jQuery selector jQuery selector