SideNav keep selected item highlighted


Topic: SideNav keep selected item highlighted

garrithsteyn pro asked 8 years ago

Hi How can I make my SideNav keep the current item selected? When I select a list item, the side nav 'resets'. If I select an item on your website, it would keep that selected item highlighted. Is there anything specific I may be missing? Thank you

Marta Szymanska staff pro premium answered 7 years ago

Hi, try this custom code: CSS: .current-menu-item { background: #33b5e5; } Jquery: $(document).ready(function () { $('.side-nav .collapsible li .collapsible-body ul li').click(function(e) { $('.side-nav .collapsible li .collapsible-body ul li.current-menu-item').removeClass('current-menu-item') $(this).closest('li').addClass('current-menu-item'); }); }); Best, Marta

Marta Szymanska staff pro premium answered 8 years ago

Hello, you need to add class .active like here:
<li><a class="collapsible-header waves-effect arrow-r active"><i class="fa fa-home"></i> Homepages<i class="fa fa-angle-down rotate-icon"></i></a>
                    <div class="collapsible-body"> 
                        <ul>
                            <li><a href="" class="waves-effect active">Default Homepage</a> 
                            </li>
                            <li><a href="" class="waves-effect">Full Width Homepage</a>
                            </li>
Best, Marta

Adam Adamczyk commented 7 years ago

With the latest version active class on item level seems to be not working - at least I do not see any difference.

Marta Szymanska staff pro premium commented 7 years ago

Hi, so how would you like this to look like? Best, Marta

mdbpenguinglu pro answered 7 years ago

@Marta active doesn't work. It's not highlighting.
Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: No
  • Technology: General Bootstrap questions
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No