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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:11:25+00:00 2026-05-24T04:11:25+00:00

I have 2 div tags which emulate a drop-down menu. When the outer div

  • 0

I have 2 div tags which emulate a drop-down menu. When the outer div is clicked, the inner div shows below it with some links. I want the inner div to hide itself only when the mouse has left either div.

Here is how the code is failing:

  1. Click the outer div.
  2. Do not enter the inner div.
  3. Move the mouse up, left or right to leave the outer div. The inner div should hide itself, but doesn’t.

I understand that I need to have a mouseout event hooked to the outer div, but when I do that, it hides the inner div when I try to enter it.

How can I get the inner div to hide itself when the mouse leaves either div?

<style type="text/css">
    div.toggleMenu { position: relative; }
    div.menu { position: absolute; left: -3px; top: 19px; display: none; }
</style>
<div class="toggleMenu">
    Toggle Menu
    <div class="menu">
        <ul>
            <a href="http://www.google.com/"><li>Google</li></a>
            <a href="http://www.yahoo.com/"><li>Yahoo</li></a>
            <a href="http://www.bing.com/"><li>Bing</li></a>
        </ul>
    </div>
</div>
<script type="text/javascript">
    // Toggle the menu.
    $('.toggleMenu').click(function ()
    {
        $(this).find('.menu').toggle();
    });

    // Hide the menu when the mouse leaves the tag.
    $('.menu').mouseleave(function ()
    {
        $(this).hide();
    });
</script>

Update: Part of my problem with the inner div disappearing when I tried to mouseover it was due to line-height issues my code was having. After closer examination (1600x zoom in IE) I found my issue and I now have jquery set the height programmatically. Here is the final code for those interested:

$('.toggleMenu').click(function ()
{
    if ($(this).find('.menu').css('display') == 'none')
    {
        // The menu needs to be positioned programmatically for the
        // height due to the differences among browser interpretations of height.
        var height = $('.toggleMenu').height() - 1;
        $(this).find('.menu').css('top', height + 'px');
        $(this).find('.menu').css('left', '-3px');
        $(this).find('.menu').show();
    }
    else
    {
        $(this).find('.menu').hide();
    }
});

// Hide the menu when the mouse leaves the tag.
$('.toggleMenu').mouseleave(function ()
{
    $(this).find('.menu').hide();
});
  • 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-24T04:11:26+00:00Added an answer on May 24, 2026 at 4:11 am

    I would try:
    http://jsfiddle.net/shaneburgess/k5WRG/1/

      // Toggle the menu.
        $('.toggleMenu').click(function ()
        {
            $(this).find('.menu').toggle();
        });
    
        // Hide the menu when the mouse leaves the tag.
        $('.toggleMenu').mouseleave(function ()
        {
            $(this).find(".menu").hide();
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It is a basic HTML question. I have some div tags, which have some
I have a Div Tag which contains 4 child Div Tags <Div id=Parent> <div
I have several Div tags on a page which are dynamic, i.e. depending on
I have a div section, which is full of <a href=> tags, on a
I have a div which contain other tags inside it <div id=mainDiv> <div> <table>
I have a div, inside of which are a few anchor links: <div id=myDiv>
I have a 2 div tags which a similar class names, the only difference
I have a div which will do some animation on click event.But I don't
I have a div which contains a series of span tags, each containing a
I have 3 div tags. Each having no. of textboxes and button. Each textbox

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.