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")
精彩评论