I've been working on a menu that functions to open and hide divs within a single page.
My objective is to have the (.active) class applied to the currently selected menu item only when its connected div is open. When the div is closed or another menu item is selected, the class should either disappear or be transferred to the new menu item.
I attempted to use
$(".your_selector li").addClass("active");
but this code simply marks all menu items as active, which is not the desired outcome.
How would you approach solving this problem? Here is the fiddle http://jsfiddle.net/4DGUV/3/
Thank you in advance