i've a list in a list like that
<ul>
<li>
<ul>
<li>something</li>
<li>something</li>
</ul>
</li>
<li>
<ul>
<li>something2</li>
<li>something2</li>
</ul>
</li>
</ul>
i use the selector (see below) to hide main list's second item but this line hides 1. sublist's second item. I want to hide main list's second item how can i do this?
$("#main_menu ul li:eq(1)").slideUp();
Try this(assuming ul
is the direct child of main_menu
).
$("#main_menu > ul > li:eq(1)").slideUp();
In your selector #main_menu ul li
will select all the li
elements within each ul
of main_menu
so you should specify just to search the immediate children by using >
child selector.