My question add and amendment to a question previously asked: jquery hide all open divs and toggle
The final answer does exactly what I want it to do but when I attempt to add an active class to the the link as well, the function stops running.
How would I also add and active class to the link that is specific to the div it is showing?
$('.stackedTabs a').on('click', function(event) {
event.preventDefault();
$('div.itemContent').hide().filter('div.' + this.className).show();
$(this).removeClass('active').filter(this).removeClass('active');
});
You're trying to essentially create a way to toggle whether or not to have an active class. This is a way to do that.
However, this is a highly googleable question and is simple enough to find.