tags:

views:

43

answers:

4
+2  Q: 

jQuery parent <li>

<ul class="menu">
<li><a href="#">texT</a>
    <ul>
        <li>text</li>
        <li>text</li>
        <li>text</li>
    </ul>
</li>
<li>text</li>
<li>text</li>
</ul>

How to get direct <li> from .menu?

<li> inside child <ul> should not be taken.

Thanks.

+4  A: 

You could try the .children() function:

var lis = ​$('.menu')​.children('li')​;
Darin Dimitrov
As opposed to $('.menu').find('li'), which would return ALL li elements underneath ul.menu regardless of depth.
Justin Russell
+1  A: 

would this work?

$(".menu > li")
John Boker
+6  A: 

You can use the child selector:

$('.menu > li')

I recommend taking a look at jQuery's selector documentation.

elusive
+2  A: 
$(".menu > li")
Philippe Leybaert