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

jQuery has() method

jQuery has() method

jQuery Traversal Methods jQuery Traversal Methods

Example

Return those having one all having two elements inside them

element:

$("p").has("span")

Try it »


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 to separate them (see the examples below).


Syntax

$(

selector

).has(

element

)

Parameters Description
element Required. Specifies a selector expression or element to match elements.

More examples

Return elements with multiple elements inside them
How to return elements with multiple elements inside them.

Return those having all of the having elements inside them

,

and
Element
How to return those having all of the having elements inside them

,

and
.

Return elements that contain links
How to return those containing hyperlinks .


jQuery Traversal Methods jQuery Traversal Methods