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 8359969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:19:07+00:00 2026-06-09T11:19:07+00:00

I am having trouble with a very simple javascript. It is supposed to show

  • 0

I am having trouble with a very simple javascript. It is supposed to show and hide the dropdown menu on my site when the mouse hovers or leaves the menu.

Problem is that my script is triggered by the ul tags of my menu and i have several ULs in my dropdown. when i hover over the menu it shows correctly but when i move the mouse down to one of the nested ULs it hides the dropdown again because of the script.

not sure how to solve this :S

this is my menu:

<div class="menu" id="menu">
        <ul>
            <li><a href="#">Forside</a></li>
            <li><a href="#">Service</a>
                <ul>
                    <li class="menusektion1">
                        <h1>Vores arbejde</h1>
                        <ul>
                            <li><a href="">projekt</a></li>
                            <li><a href="">projekt2</a></li>
                            <li><a href="">projekt3</a></li>
                            <li><a href="">projekt4</a></li>
                        </ul>
                    </li>
                    <li class="menusektion2">
                        <h1>Menupunkt2</h1>
                        <ul>
                            <li><a href="">Title</a></li>
                            <li><a href="">Title2</a></li>
                            <li><a href="">Title3</a></li>
                            <li><a href="">Title4s</a></li>
                        </ul>
                    </li>
                </ul>
            </li>
            <li><a href="#">Projekter</a></li>
            <li><a href="#">Referencer</a></li>
            <li><a href="#">Kontakt</a></li>
        </ul>    
    </div>

this is my javascript:

    $(document).ready(function(){   
  $('#menu ul > li')
    .mouseenter(function(){
      $(this).find('ul').show();
    })
    .mouseleave(function(){
      $(this).find('ul').hide();
    }); 
});

can someone help me out here?

  • 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-06-09T11:19:10+00:00Added an answer on June 9, 2026 at 11:19 am

    I understand you want to hide the ul tag inside the hovered li tag. Your syntax is almost correct.
    Problem is, I think, you’re adding the event listeners to all li tags inside your menu.
    Try this :

    $('#menu > ul > li').mouseenter(function(){});
    

    This way the ul and li tags inside the first level ul will lot be affected.

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

Sidebar

Related Questions

I'm having trouble with a seemingly very simple problem: I want to get a
I'm having some trouble doing a very simple task. I have a rich textbox
I am having trouble implementing image rotation in CUDA. I have a very simple
I'm sure it's very simple, but I'm having trouble figuring out how to alter
Having some trouble with what should be a very simple scenario. For example purposes,
I'm having some trouble with Visual Studio 2008. Very simple program: printing strings that
So this one is probably very simple, but I'm having a bit of trouble
I'm very new to JavaScript in general so having trouble with this. Working with
OK, knowledgeable programmer-types, please be gentle... I'm having trouble getting a very simple, one-view
This is really bothering me. I'm having trouble with some very very simple logic.

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.