Given the following html:
<ul class="sub-categories">
<li>
<a href=""><img src="" alt=""></a>
<h2 class="sub-header">
<a href="">category name</a>
</h2>
</li>
</ul>
I want to add the class 'current' to the 'a' tag inside '.sub-header' irrespective of which anchor is clicked.
The following works only when I click the first anchor.
$('ul.sub-categories li a').click(function(event) {
event.preventDefault();
$(this).next(".sub-header").children('a').addClass("current");
});
How do I make it work irrespective of which anchor is clicked ?