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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:27:46+00:00 2026-05-13T07:27:46+00:00

I’m trying to create a drop-down menu acting as the sub-menu of a main

  • 0

I’m trying to create a drop-down menu acting as the sub-menu of a main menu. The sub-menu is simply a div element containing items/links. When a main menu item is clicked, the sub-menu drops down and stays there. That’s all easy, but I want the sub-menu to slide back up if the cursor leaves the sub-menu. In other words, a simple ‘mouseout’ event. It seems, however, that when the cursor enters one of the items inside the sub-menu, the ‘mouseout’ event is triggered. That’s what you would except, if you think about it, as the cursor does leave the sub-menu element even though it doesn’t leave its boundries. However, this does pose a problem, because I only want the event to fire if the cursor is moved outside the boundries of the sub-menu element.

What it really boils down to, is having one div inside another div, like this:

----------------------------
|          DIV-1           |
|                          |
|      -------------       |
|      |           |       |
|      |   DIV-2   |       |   AREA OUTSIDE DIV-1
|      |           |       |
|      |           |       |
|      |           |       |
|      -------------       |
|                          |
|                          |
----------------------------

Now, 2 things may cause DIV-1 to fire a ‘mouseout’ event:

  1. The cursor moves from within the boundries of DIV-1 to the area outside those boundries
  2. The cursor moves from within the boundries of DIV-1 to the area of DIV-2

My goal is to be able to distinguish these two occurences from one another, yet I haven’t been able to figure out how.

Does anyone have a good solution for this problem? It seems a common enough feature, so someone must have solved it.

  • 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-13T07:27:46+00:00Added an answer on May 13, 2026 at 7:27 am

    Since mouseover events from child elements bubble/propagate to the parents, I would use a timer that is cancelled in the onmouseover event of the sub menu’s div, if I was going the non-library route:

    var hideMenuTimer;
    subMenuDiv.onmouseover = function () {
        window.clearTimeout(hideMenuTimer);
    }
    subMenuDiv.onmouseout = function (evt) {
        evt = evt || window.event;
        if ((evt.target || evt.srcElement).id == "subMenuDiv")
            hideMenuTimer = window.setTimeout(function () {
                subMenuDiv.style.display = "none";
            }, 300);
    }
    

    A very simple example but it should work, providing all sub elements of the sub menu div correctly bubble the onmouseover event to the subMenuDiv element then the timer is cancelled before it polls. Also, I’ve put a 300ms timeout because I think it’s best to have this sort of thing so that if you accidentally mouseout you have a short window to get the mouse back in before it hides. If you want it to hide instantly, setting it to 0ms should work fine too.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

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.