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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:55:41+00:00 2026-05-24T22:55:41+00:00

The desired behavior is: click on parent to open dropdown menu click anywhere on

  • 0

The desired behavior is:

  • click on parent to open dropdown menu
  • click anywhere on page or on parent, to close dropdown menu

My jQuery code works fine in Safari & Firefox, but not in IE 8. In IE 8 the dropdown menu opens and closes again when the parent is clicked for the first time. The second time the parent is clicked the dropdown menu stays open. I am using jQuery 1.6.2.

Here’s the jQuery code (a bit of a Frankenstein I have cobbled together from different methods I read about):

$(function() {
/* for keeping track of what's "open" */
    var activeClass = 'menu-open', showingDropdown, showingMenu, showingParent;
    /* hides the current menu */
    var hideMenu = function() {
        if(showingDropdown) {
            showingDropdown.removeClass(activeClass);
            showingMenu.fadeOut(500);
        }
    };

    /* recurse through dropdown menus */
    $('.drop').each(function() {
        /* track elements: menu, parent */
        var dropdown = $(this);
        var menu = dropdown.next('.subnav'), parent = dropdown.parent();
        /* function that shows THIS menu */
        var showMenu = function() {
            hideMenu();
            showingDropdown = dropdown.addClass('menu-open');
            showingMenu = menu.show();
            showingParent = parent;
        };
        /* function to show menu when clicked */
        dropdown.attr('href','/#dropdown').bind('click',function(e) {
            if(e) e.stopPropagation();
            if(e) e.preventDefault();
            if ( dropdown.hasClass('menu-open') ) {
                hideMenu();
            } else {
                showMenu();
            }
        });
        /* function to show menu when someone tabs to the box */
        dropdown.bind('focus',function() {
            showMenu();
        });

    });
});

It would be much appreciated if anyone could give me a pointer as to why IE would be behaving differently than Webkit & Firefox. A link to an existing solution that does what I describe would also be great. Please explain as if you were talking to a slow child, because jQuery / Javascript is not my forte.

  • 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-24T22:55:42+00:00Added an answer on May 24, 2026 at 10:55 pm

    showMenu(); is getting called on focus (mouse down) then on “click” (mouse release) hideMenu(); is getting called which is why if you click on it again it works because it’s already focused. but if you were to click off of it I bet you would get the the same behaviour.. I would remove ‘focus’ code imo or make “focus” so it doesn’t interfere with “click”

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

Sidebar

Related Questions

The following jQuery Javascript code is included on an otherwise empty page. var element;
Example of failure: http://progamonth.com/files/testfile.html Desired Behavior: Ideally, any headers with a colspan shouldn't affect
I have the following jsFiddle: http://jsfiddle.net/tad604/dpRca/2/ That works as desired on IE and Chrome,
I am trying to put some jquery UI code into an existing asp.net app,
I am learning jQuery and as part of that i tried following code.. It
Desired behavior An undecorated non-nullable value-type property in a model automatically gets a validation
I need to investigate/test the behavior of some code on Linux under conditions where
The desired behavior is akin to the mirrored text editing field provided in Excel
I am having problems getting the desired behavior out of these few classes and
I have a FireWorks-generated HTML page and I added some jQuery to it for

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.