开发者

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 t开发者_如何转开发o get direct <li> from .menu?

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

Thanks.


You can use the child selector:

$('.menu > li')

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


You could try the .children() function:

var lis = ​$('.menu')​.children('li')​;


$(".menu > li")


would this work?

$(".menu > li")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜