I created a navigation bar with the following structure:
<ul class="nav">
<li class="active"><a href="blah.html">S</a></li>
<li><a href="blah1.html">S1</a></li>
<li><a href="blah2.html">S2</a></li>
<li><a href="blah3.html">S3</a></li>
</ul>
During an event, I have access to the a
element that the user clicked on.
$('.nav').on('click', 'li a', function(){
var clickedLink = $(this);
var prevActiveLI = ?
var currentClickedAnchorsParentLI = ?
});
I need to retrieve two things for my purpose - the previous li
tag that has the active
class and the li
tag corresponding to the a
that was just clicked. How can this be achieved?