I need to select the first lis of each ul in this structure:
<div>
<ul>
<li></li>
<li></li>
<li></li>
</ul>
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</div>
I have this selector: container.find('div > ul > li:first') but jquery engine parese first div > ul > li and then takes the forst result according to :first. But I want the first li of each ul, something like: div > ul > (li:first).
How can I solve this?
You want the
:first-childselector:ref: http://api.jquery.com/first-child-selector/
Example:
Or if you have multiple levels of
ulcontainingli‘s: