Andrew Ceban
Andrew Ceban

Reputation: 118

Second menu doesn't add .active class while navigation

Hi everyone I am building a website on Joomla 2.5 where I have 2 menus one is main menu and other is second menu that appears only on some pages. Main menu works great it adds .active class while navigation ex: if clicked:

<li class="item111 active root ">

if not clicked

<li class="item111 root ">

but second one doesn't apply this functionality by default I do not know why:

<ul id="slide-menu" class="menu menu-sidebar">
  <li class="level1 item187">
    <a class="level1" href="/plastikovye-okna-i-dveri/other/plastikovye-okna-i-dveri">
     <span>Пластиковые окна</span>
    </a>
  </li>
  <li class="level1 item188">
    <a class="level1" href="/plastikovye-okna-i-dveri-2/uncategorised/okna-rehau">
     <span>Входные двери</span>
    </a>
  </li>
</ul>

I tried to add this class with javascript but it doesn't work too, any thoughts on that?

<script>
$(function(e){

  $("#slide-menu > li ").click(function(){
    e.preventDefault();
    $("#slide-menu > li ").addClass("current").not(this).removeClass("current");
  });

});

</script>

website link you can see the menu just next to the slider

Upvotes: 0

Views: 149

Answers (1)

karaxuna
karaxuna

Reputation: 26930

Try this:

$(function(){
  $("#slide-menu > li ").click(function(e){
    e.preventDefault();
    $("#slide-menu > li ").addClass("current").not(this).removeClass("current");
  });
});

Upvotes: 2

Related Questions