Latest web development tutorials

jQuery has () method

jQuery traversal methods jQuery traversal methods

Examples

Back has a <span> element in all <p> elements within it:

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

try it"

Definition and Usage

has () method returns all elements that match the specified selector has one or more elements therein.

Tip: To select more than one element has elements in it, use a comma-separated (see example below).


grammar

$(selector).has( element )

参数 描述
element 必需。规定匹配元素的选择器表达式或元素。

Examples

More examples

Returns the element with a plurality of elements therein
How to return an element with a plurality of elements therein.

Returns have <span> element within all <p>, <h3> and <div> elements
How to Return has a <span> element within all <p>, <h3> and <div> elements.

Returns the element that contains the link
How to Return contains hyperlinks <span> element.


jQuery traversal methods jQuery traversal methods