thinkbliss thinkbliss - 1 year ago 64
CSS Question

Simple add class to the link of toggled div

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) {
$('div.itemContent').hide().filter('div.' + this.className).show();

Ale Ale
Answer Source

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.

$('.stackedTabs a').on('click', function(event) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download