here is html:
If i will press 'a' link it will addClass 'current' to clicked li and remove old li class
Use
Try this: Works fine for me..
<ul>
<li class="current"><a href="#">menu item</a></li>
<li><a href="#aba">menu item</a></li>
<li><a href="#abb">menu item</a></li>
<li><a href="#abc">menu item</a></li>
<li><a href="#abd">menu item</a></li>
</ul>
If i will press 'a' link it will addClass 'current' to clicked li and remove old li class
Use
.parent('li')
or .closest('li')
to select the clicked <li>
.$('ul li a').click(function() {
$('ul li.current').removeClass('current');
$(this).closest('li').addClass('current');
});
Try this: Works fine for me..