jQuery has()Method
Examples
Return all <p> elements that have a <span> element inside them:
$("p").has("span")
Try it Yourself »
Definition and Usage
The has() method returns all elements that have one or more elements inside them matching the specified selector.
Tip:To select elements that have multiple elements inside them, use a comma separator (see example below).
Syntax
$(selector).has(element)
| Parameter | Description |
|---|---|
| element | Required. Specifies a selector expression or element that matches elements. |
More Examples
Return elements with multiple elements inside them
How to return elements with multiple elements inside them.
Return all <p>, <h3> and <div> elements that have a <span> element inside them
How to return all <p>, <h3> and <div> elements that have a <span> element inside them.
Return elements containing links
How to return <span> elements that contain hyperlinks.
Other Extensions
jQuery Traversal Methods