I've been searching for the past couple of days, however, I haven't been able to find a solution which resolves all the constraints I'm currently facing. Any help would be much appreciated.
jQuery is already being used on the page.
Current Scenario
I have an existing page with multiple panels. Each panel has a small navigation menu (a horizontal UL list) which is used to Show/Hide layers within that panel. The Show/Hide function is working as intended.
What is missing
Highlight currently active menu item when clicked and restore the previously active item to inactive by changing class.
Constraints
- The classes - active/inactive are applied to
<a>
tag - The design is such that both the active/inactive classes are unique i.e. we can not assign a common class (e.g. .selected) to a group of or all hyperlinks
- There are multiple such unique groups on the page and I need to be able to target them individually.
jsFiddle
Please refer to the jsFiddle illustration here.
HTML Code
The basic block of HTML that I'm working with is as follows:
<div id="panel">
<div id="navwrapper">
<ul id="nav">
<li><a href="javascript:showhide('div_1');" class="grp1_1_selected">One</a></li>
<li><a href="javascript:showhide('div_2');" class="grp1_2">Two</a></li>
<li><a href="javascript:showhide('div_3');" class="grp1_3">Three</a></li>
</ul>
</div>
<div id="div_1" name="group1">Some content here for Div 1</div>
<div id="div_2" name="group1">Some content here for Div 2</div>
<div id="div_3" name="group1">Some content here for Div 3</div>
</div>
There are multiple such panels (each unique) on the page, thus the other similar solutions fail to work.