My HTML looks like this:
<li class="li-top"><a class="top sub" href=#>Blah</a> .... </li>
What I am trying to do is to select the anchor tag, so I can change the color of the text ("Blah"). But here's the catch: I am using closest() because I am starting from a descendant of that li tag:
$(this).closest('li.li-top');
How do I get that anchor tag from this starting point? I tried next(), each(), children(), etc. I can't get it. Thanks.
If you're starting from one of the children, you might try:
$(this).parents('li.li-top').find('a:first');
I often go this way to find 'cousins once removed' in the DOM.
This way probably:
$('li.li-top a:first')
Or:
$(this).find('li.li-top a:first')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With