Filters the set of matched elements to only those which have the given DOM element as a descendant or which have a descendant that matches the given selector. Equivalent to .filter(':has(selector)').
.filter(':has(selector)')
Element to look for.
The filtered collection.
$('ul').has('.pear').attr('id');//=> fruits Copy
$('ul').has('.pear').attr('id');//=> fruits
$('ul').has($('.pear')[0]).attr('id');//=> fruits Copy
$('ul').has($('.pear')[0]).attr('id');//=> fruits
https://api.jquery.com/has/
Filters the set of matched elements to only those which have the given DOM element as a descendant or which have a descendant that matches the given selector. Equivalent to
.filter(':has(selector)').