Select Elements Having Inner Element Matching selector $(":has(selector)")

$(":has(selector)")

e.g. $("ul:has([id])")

$(":has(selector)") selects each element that has at least one of its inner elements matching selector.

For example, $("ul:has([id])") will find each <ul> element that has at least one inner elements with id attribute.


<ul>
   <li>a</li>
   <li id>b</li>
   <li>c</li>
</ul>
    
<ul>
  <li>d</li>
  <li>e</li>
  <li>f</li>
</ul>
jQuery selector filter $(":has(selector)")