Learn all about the jQuery function .has().
Given a jQuery object that represents a set of DOM elements, the
.has() method constructs a new jQuery object from a subset of the matching elements. The supplied selector is tested against the descendants of the matching elements; the element will be included in the result if any of its descendant elements matches the selector.
Consider a page with a nested list as follows:
We can apply this method to the set of list items as follows:
The result of this call is a red background for item 2, as it is the only
<li> that has a
<ul> among its descendants.