This is my setup:
<div id="nav">
<ul>
<li><a href="#">MENU ENTRY</a></li>
<li><a href="#">MENU ENTRY WITH SUBMENU</a>
<ul>
<li><a href="#">SUBMENU ENTRY</a></li>
<li><a href="#">SUBMENU ENTTY</a></li>
</ul>
</li>
</ul>
</div>
Now I tried to achieve the following with jQuery:
- Check if "#nav li" has another "ul"
- If so, find the "a"-Tag and append a "span"-Tag to it
Like this:
$("#nav li").has("ul").find("a").append('<span class="test">SOMETHING</span>');
Unfortunately the "span"-Tag is appended to all children "a"-Tags.
I tried to remove the class from the other "a"-Tags, but it does not work.
$("#nav li ul li").find("a").remove(".test");
And here's the fiddle: http://jsfiddle.net/LmDYg/6/
Help would be appreciated, thanks!