<ul>
<li><a href="#">item 1</a></li>
<li><a href="#">item 2</a></li>
<li><a href="#">item 3</a></li>
</ul>
По щелчку я хотел бы к addclass active
к родительскому элементу лития, также удаляя active
класс от любого другого элемента, который уже может быть активным.
$("li a").click( function() {
$(".active").removeClass("active");
$(this).parent("li").addClass("active");
});
$('div.filter').delegate('a', 'click', function (event) {
var theLi = $(this).closest('li');
theLi.siblings('.active:first').removeClass('active');
theLi.addClass('active');
$('ul.items li').hide().filter('.' + this.href.slice(this.href.indexOf("#") + 1)).show();
event.preventDefault();
});