开发者

Add Classes to first level list tags

is there a way to add class to only one level on li tags? in m case at the moment it looks like this:

<ul>
    <li></li>
    <li>
        <ul>
            <li></li>
            <li></li>
        </ul>
    </li>开发者_Go百科;
    <li></li>
</ul>
And this is what I need
<ul>
    <li class="lev-one"></li>
    <li class="lev-one">
        <ul>
            <li></li>
            <li></li>
        </ul>
    </li>
    <li class="lev-one"></li>
</ul>

Thank you for your help in advance.

Dom


Try this:

$("*:not(li) > ul > li").addClass("lev-one")
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜