javascript - Find specific parent of element in AngularJS directive -


i have list setup so

<div id="timelineright" data-sticky-to="#rightpanel">     <ul class="timelinehighlights">         <li>             <a href="">2015</a>             <ul>                 <li><a href="" spy="2015-07">july</a></li>                 <li><a href="" spy="2015-06">june</a></li>                 <li><a href="" spy="2015-05">may</a></li>                 ... 

i have function gets called when page scrolling should change navigation in list. works want add class parent on scrolling.

i.e. if june highlighted (using current class) want 2015 highlighted.

currently code add class looks so:

elem.addclass("current"); 

in straight jquery, selector i'd following:

elem.closest("ul").closest("li").find("a").first().addclass("current") 


Comments