I’m needing to grab a specific element. I have an event that triggers when I click the a tag. I’m having trouble reaching it since I can only effect the ul that the a tag is inside. The element I want to select has a class of target. The obvious answer is to select target, but there are multiple target classes. My question is how do I target the element I want. Below is the code.
<div id="section">
<div id="target">
Here is the div that I want to target. But I can't target it.
</div>
<div>
<ul>
<li></li>
<a>Clicking here triggers the event.</a>
<li></li>
</ul>
</div>
</div>
<script>
$(a).parentsUntil('#section').children(':gt(0)').children(':gt(2)').css('color','red');
</script>
1 Answer