Looking at the following markup:
<ul>
<li> // this
<ul>
<li>
<div></div>
</li>
<li>
<div></div>
</li>
</ul>
</li>
<li> // this
<ul>
<li>
<div></div>
</li>
<li>
<div></div>
</li>
</ul>
</li>
</ul>
In my CSS style, I currently have:
.main_menu ul > li {
// some style
}
This applies the style only to the first li
in the hierarchy, not its children. So, my question is how can I achieve this using jQuery? When I try with $('.main_menu ul > li');
, it doesn't work. I assume that I need something like this:
$('.main_menu ul').each().first().child();
However, this code is incorrect. Can anyone provide guidance on how to accomplish this?