Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7051285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:14:43+00:00 2026-05-28T03:14:43+00:00

I have to make a dynamic menu in javascript, so I use onMouseOver and

  • 0

I have to make a dynamic menu in javascript, so I use onMouseOver and onMouseOut, but the problem is when I focus my mouse on line space, the menu dissapear because it think I’m no more in the div!

<script type="text/javascript">
function cacherSousMenu(menu)
{
    if(menu == "ajout")
    {
        document.getElementById('sousMenuAjout').style.display = document.getElementById('sousMenuAjout').style.display=='none'?'block':'none';
        document.getElementById('imgPlusMoinsAjout').src = document.getElementById('sousMenuAjout').style.display=='none'?'images/plus.gif':'images/moins.gif';
    }
    else if(menu == "inscrire")
    {
        document.getElementById('sousMenuInscrire').style.display = document.getElementById('sousMenuInscrire').style.display=='none'?'block':'none';
        document.getElementById('imgPlusMoinsInscrire').src = document.getElementById('sousMenuInscrire').style.display=='none'?'images/plus.gif':'images/moins.gif';
    }
}

<nav>
<ul>
<div id="ajouter" onmouseover="cacherSousMenu('ajout');">
<li class="titre">Ajouter <img src="images/plus.gif" id="imgPlusMoinsAjout" alt="Image Plus Moins"></li>
</div>
<div id="sousMenuAjout" onmouseout="cacherSousMenu('ajout');">
<ul>
<li><a href="index.php?page=3">Un établissement</a></li>
<li><a href="index.php?page=4">Une filière</a></li>
<li><a href="index.php?page=5">Une UE</a></li>
</ul>
</div>
<div id="inscrire" onmouseover="cacherSousMenu('inscrire');">
<li class="titre">Inscrire <img src="images/plus.gif" id="imgPlusMoinsInscrire" alt="Image Plus Moins"></li>
</div>
<div id="sousMenuInscrire" onmouseout="cacherSousMenu('inscrire');">
<ul>
<li><a href="index.php?page=2">Un nouvel étudiant</a></li>
<li><a href="index.php?page=6">Un étudiant à une UE</a></li>
</ul>
</div>
<li class="titre"><a href="index.php?page=7">Afficher tous les étudiants</a></li>
<li class="titre">Aide</li>
<ul>
</nav>

So, how to correct that, maybe with CSS?

Thank!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:14:44+00:00Added an answer on May 28, 2026 at 3:14 am

    I can’t help but wonder if you should post a question (or look for one) on https://ux.stackexchange.com/ about menu behaviour, and in particular, hover states (which don’t exist on pads and phones which are becoming more prolific). But to solve your technical issue…

    It takes a lot more than just mouse over and mouse out to make a menu behave nicely. Most good menus allow a grace period for user error, meaning the mouse can leave the menu briefly. Again, to simply solve your technical issue of the menu flashing when you move your mouse:

    You have DIVs and list items mixed up a little. I’ve added some bright colours to help clarify the elements, and converted the DIVs to list items for simplicity. I also refactored your JavaScript method to make it slightly less tightly coupled with your markup. I hope you find it useful.

    <!doctype HTML>
    <html>
    <head>
    <style>
    .titre {background-color:red;}
    .menuItemWrapper {background-color:green;}
    </style>
    </head>
    <body>
    <nav>
        <ul id="ajouter" onmouseover="showMenu('sousMenuAjout','imgPlusMoinsAjout',true);" onMouseOut="showMenu('sousMenuAjout','imgPlusMoinsAjout',false);">
                <li class="titre">Ajouter <img src="images/plus.gif" id="imgPlusMoinsAjout" alt="Image Plus Moins"></li>
            <ul id="sousMenuAjout" class="menuItemWrapper" onMouseOut="hideMenu('sousMenuAjout');">
                    <li><a href="index.php?page=3">Un établissement</a></li>
                    <li><a href="index.php?page=4">Une filière</a></li>
                    <li><a href="index.php?page=5">Une UE</a></li>
                </ul>
        </ul>
    
        <ul id="inscrire" onmouseover="showMenu('sousMenuInscrire','imgPlusMoinsInscrire',true);" onMouseOut="showMenu('sousMenuInscrire','imgPlusMoinsInscrire',false);">
            <li class="titre">Inscrire <img src="images/plus.gif" id="imgPlusMoinsInscrire" alt="Image Plus Moins"></li>
            <ul id="sousMenuInscrire" onmouseout="cacherSousMenu('inscrire');" class="menuItemWrapper">
                <ul>
                    <li><a href="index.php?page=2">Un nouvel étudiant</a></li>
                    <li><a href="index.php?page=6">Un étudiant à une UE</a></li>
                </ul>
            </ul>
            <li class="titre"><a href="index.php?page=7">Afficher tous les étudiants</a></li>
            <li class="titre">Aide</li>
        </ul>
    </nav>
    <script type="text/javascript">
    function showMenu(menuId, menuIconId, visible) {
        var displayStyle, imageName;
        if (visible) {
            displayStyle = 'block';
            imageName = 'images/moins.gif';
        } else {
            displayStyle = 'none';
            imageName = 'images/plus.gif';
        }
        document.getElementById(menuId).style.display = displayStyle;
        document.getElementById(menuIconId).src = imageName;
    }
    showMenu('sousMenuAjout', 'imgPlusMoinsAjout', false);
    showMenu('sousMenuInscrire', 'imgPlusMoinsInscrire', false);
    </script>
    </body>
    </html>
    

    You can see this live on jsbin (doesn’t work in jsFiddle for some reason):
    http://jsbin.com/exakiz/2

    PS. Sorry I switched some names to English; I don’t speak or understand French. 🙁

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to make a dynamic menu in java swing. I have a database
I have the following javascript which I need to make dynamic. data.addRows(2); data.setValue(0, 0,
I have to make dynamic hashes, so the class example won't work since the
I have to make a decision of which database server to use for my
I have to make something like an accordion, but I want it to fade
I have created a dynamic dependent menu using a jquery script i found on
i have to make an addchild to a movieclip, but i really don't know
I have an HTML menu in a partial and I want to make the
i have an xml file. how to make dynamic xml? <?xml version=1.0 encoding=ISO-8859-1?> <jukebox>
I'm trying to make a dynamic chart using HighCharts, but as it seems to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.