tags:

views:

43

answers:

1

Hi,

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>
    <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

+4  A: 

Try this:

$("*:not(li) > ul > li").addClass("lev-one")
Gumbo
That will add the class to the `ul` elements
Philippe Leybaert
@Philippe Leybaert: Fixed that.
Gumbo
+1. I tested this with chrome and it works.
Jim Schubert