Easy Tutorial
❮ Misc_Each Jquery Ref Html ❯

jQuery :has() Selector

jQuery Selectors

Example

Select all <p> elements that contain a <span> element within them:


Definition and Usage

The :has() selector selects elements that contain one or more elements within them, matching the specified selector.

Tip: To select elements that contain multiple elements within them, use a comma (see the example below).


Syntax

Parameter Description
selector Required. Specifies the element to select. <br>This parameter accepts any type of selector.

Try It - Example

Select elements containing multiple elements within

Select elements not containing specified elements within


jQuery Selectors

❮ Misc_Each Jquery Ref Html ❯