Thursday, 12 September 2013

highlight the current menu using variable in jquery

highlight the current menu using variable in jquery

<ul class="topMenu" style="padding-top: 35px;">
<li class="acB"><span><a id="configure" title="Configure">CONFIGURE
</a></span></li>
<li><span><a id="accounts" title="Accounts">ACCOUNTS</a> </span></li>
<li><span><a id="forwarding"
title="Forwarding">FORWARDING</a></span></li>
<li><span><a id="container_track" title="Container Track">CONTAINER
TRACK</a></span></li>
<li><span><a id="fleet_management" title="Fleet Management">FLEET
MANAGEMENT</a> </span></li>
</ul>
And the CSS:
.topMenu li.acB {
color: #fff;
background-color: #F36501;
border-bottom: 1px solid #4F556B;
}
How can I highlight the selected menu? I've tried this:
$("#accounts").closest('ul').find('.acB').removeClass('acB');
$("#accounts").parents().addClass('acB');
$("#accounts").parent().children().removeClass('acB');
Create one variable do the above process and declare the menu level.

No comments:

Post a Comment