Reputation:
I think all I need is a selector, but can't find one. I want to select the anchor tag, but can only select the li
using .parent()
...
jQuery:
$("nav ul li > ul").parent().append('<span class="arrow">↓</span>');
HTML:
<li><a href="#">The Events</a>
<ul>
<li><a href="#">Schedule</a></li>
<li><a href="#">Buy Tickets</a></li>
<li><a href="#">Features</a></li>
</ul>
</li>
The code above puts the arrow on the right li
s, but one level to high. I need to target the li
's a
tag.
Upvotes: 1
Views: 2454
Reputation: 630637
You can use .siblings()
, like this:
$("nav ul li > ul").siblings("a").append('<span class="arrow">↓</span>');
You can find a full list of traversal functions here.
Upvotes: 4
Reputation:
Answered myself. Using .children("a")
I was able to select the anchor. Final code looked like:
$("nav ul li > ul").parent().children("a").append('<span class="arrow">↓</span>');
Upvotes: 0