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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:21:06+00:00 2026-06-07T21:21:06+00:00

I am mocking up a simple multi-level drop down box and cannot figure out

  • 0

I am mocking up a simple multi-level drop down box and cannot figure out how to get the hover event to fire only once when a li is hovered. The hover event fires twice when the a tag inside of the list-item is hovered.

Here is a jsFiddle that demonstrates the problem. I’ve added extra padding around the a tag to show how the event is fired twice. If just the padding is hovered, the event will fire once, but once the a tag is hovered, it will fire again.

HTML:

<ul class="dropit">
    <li><a href="#">Thing 1</a></li>
    <li><a href="#">Thing 2</a></li>
    <li><a href="#">Thing 3</a>
      <ul>
        <li><a href="#">Sub-thing 1</a></li>
        <li><a href="#">Sub-thing 2</a>
           <ul class='sub-menu'>
            <li><a href="#">Sub-sub-thing 1</a></li>
            <li><a href="#">Sub-sub-thing 2</a></li>
          </ul>
        </li>
      </ul>
    </li>
</ul>

jQuery:

$(document).ready(function(e) {
    $('ul.dropit li').on('mouseover', function(event) {
        $target = $(event.currentTarget);
        $sub = $target.children('ul').first();
        $sub.slideToggle();
    }).on('mouseout', function(event) {
        $target = $(event.currentTarget);
        $target.children('ul').first().slideToggle();
    });
});

jsFiddle demonstration

  • 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-07T21:21:08+00:00Added an answer on June 7, 2026 at 9:21 pm

    Use mouseenter and mouseleave instead of mouseover and mouseout

    FIDDLE

    $(document).ready(function(e) {
        $('ul.dropit li').on('mouseenter', function(event) {
            $target = $(event.currentTarget);
            $sub = $target.children('ul').first();
            $sub.slideToggle();
        }).on('mouseleave', function(event) {
            $target = $(event.currentTarget);
            $target.children('ul').first().slideToggle();
        });
    });​
    

    mouseover will fire when you hover over a child element.

    mouseenter fires only once no matter how many children are hovered.

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

Sidebar

Related Questions

I'm new to mocking/testing and wanting to know what level should you go to
I have a test where I'm mocking 2 service calls that get called in
What is the best approach for mocking out a static class in c#. For
Is it true that mocking frameworks in general and Rhino mocking in specific only
I'm teaching myself Rails, and as a test project I'm mocking up a simple
I'm attempting to do some simple mocking of a Domain class within a unit
I am having trouble mocking in my unit tests so I made a simple
I'm using OCMock 1.70 and am having a problem mocking a simple method that
Anyone have any tips for best practices for mocking out facebook requests in functional
I am making a simple snippet that should pass a Box[String] with the requests

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.