user2460074
user2460074

Reputation: 1272

how to remember the active menu

I have a menu with sub menu(vertical). My first li is active with the sub menu because i'm in the current page but My problem is when I hover in the next li I have the sub menu display it but if i lost the active li when i quits the menu

What I need is:

  1. when my cursor is not hovering in my menu, i need the default sub menu that has the on class

This what i look do it enter link description here

this link of my code in FIDDLE enter link description here

Upvotes: 0

Views: 65

Answers (1)

Yuriy Yakym
Yuriy Yakym

Reputation: 3921

I've changed your css so you don't need any js now. It works this way:

  • In normal state an element with .on class is displayed;
  • When you hover #menu then we hide all the .niveau2 elements
  • When you hover some tab then we show only its .niveau2 element by adding an !important keyword to display property.
#menuu ul li:hover ul{
   display: inline-block !important;    
}

#menuu ul:hover .niveau2 {
    display: none;
}

#menuu .on {
    display: block;
}

Here is an example with my changes: http://jsfiddle.net/bymb6kvm/14/

Upvotes: 1

Related Questions