I have a fairly large, three level deep, menu consisting of nested lists like in this example
<ul class="nav">
<li><a href="#">1</a>
<ul>
<li><a href="#">2</a>
<ul>
<li><a href="#">level 3</a></li>
<li><a href="#">level 3</a></li>
<li><a href="#">level 3</a></li>
</ul>
</li>
<li><a href="#">2</a>
</ul>
</li>
</ul>
For the menu I would like to work with two levels only so I would like to remove the third ul
and add a class to its (former) children for styling purposes.
Can this be done with jQuery? The result should be looking something like:
<ul class="nav">
<li><a href="#">1</a>
<ul>
<li><a href="#">2</a></li>
<li class="third"><a href="#">level 3</a></li>
<li class="third"><a href="#">level 3</a></li>
<li class="third"><a href="#">level 3</a></li>
<li><a href="#">2</a></li>
</ul>
</li>
</ul>
Any help is appreciated!