I’ve read this SO question :
jQuery – select children which has specific styles
but my problem is a bit different.
I want to select PARENTS that their 1st-level children (not all descendants) have some certain styles. Something like this :
<ul id="BIG">
<li>Home
<ul id="SMALL">
<li> 123 </li>
<li name="foo"> 123 </li>
<li> 123 </li>
</ul>
</li>
<li>Articles</li>
<li>Petitions</li>
<li>Contact</li>
</ul>
And I want to catch the UL with id=”SMALL”. But my selector catch all 2 UL tags :
$('ul:has(li[name="foo"])')
Any suggestion ?
Use the child selector
>, like this:See working demo