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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:58:17+00:00 2026-06-04T03:58:17+00:00

When users toggle the $(‘#menu’); button, they have no problem. However, when users mouseleaves

  • 0

When users toggle the $('#menu'); button, they have no problem. However, when users mouseleaves the $('#dropdown'); then click back the $('#menu'); they have to click twice in order for the toggle to work again. Am I doing something wrong?

jsfiddle demo

===========HTML===========

<a class="" href="javascript:;" id="menu"></a>
<div style="display: none;" id="dropdown">
  <div id="wrap">
    <div class="menu-section">
      <div class="menu-header-section">
        <h3>Header</h3>
      </div>
      <div class="menu-list">
        <ul class="list">
          <li><a href="#">link</a></li>
          <li><a href="#">link</a></li>
        </ul>
      </div>
    </div>
  </div>
  <a href="javascript:;" class="closeThis">close</a> </div>
</div>

===========jQuery===========

    //menu
var menu = $('#menu');
var dropdown = $('#dropdown');

menu.toggle(function () {
    menu.addClass('active');
    dropdown.fadeIn();
}, function () {
    menu.removeClass('active');
    dropdown.fadeOut();
    return false;
});
dropdown.mouseleave(function () {
    menu.removeClass('active');
    dropdown.fadeOut();
    return menu;
});
  • 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-04T03:58:19+00:00Added an answer on June 4, 2026 at 3:58 am

    The docs explain it all:

    .toggle( handler(eventObject), handler(eventObject) [, handler(eventObject)] )
    handler(eventObject)
    A function to execute every even time the element is clicked.
    handler(eventObject) A function to execute every odd time the element is clicked.

    The .toggle() method binds a handler for the click event, so the rules outlined for the triggering of click apply here as well.

    In other words, toggle() alternates based on even and odd click events. So:

    • click [odd]: Show
    • click [even]: Hide

    • click 1: Show

    • click 1: Show
    • click 2: Hide
    • click 3: Show
    • click 4: Hide
    • click 5: Show
    • mouseleave: Hide
    • click 6: Hide // Notice that #dropdown is already hidden here, but regardless, it’s an even click. Click once, and you’re hiding it again.
    • click 7: Show // Click twice to show.

    Anyways, that’s the explenation for your problem. Working on solution.


    Solution

    Manually trigger the click event.

    Replace:

    dropdown.mouseleave(function () {
        menu.removeClass('active');
        dropdown.fadeOut();
        return menu;
    });
    

    With:

    dropdown.mouseleave(function () {
        menu.trigger('click');
    });
    

    Demo: http://jsfiddle.net/aymansafadi/BF8p6/2/

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

Sidebar

Related Questions

I have a chat feature on my site, and users click a button to
I have inherited a jquery component that simulates a dropdown for users to choose
So I'm trying to have a button where users can choose between flash on/off/auto.
I want to toggle disabled/enabled for a form based on a users click of
thanks to Nick Craver I've got a nice toggle menu going, however i've come
I have this jquery: $(.button).toggle(function() { $(this).find(.button).addClass('disable'); }, function(){ $(this).find(.button).removeClass('disable'); }); My html for
We have an ASP.Net page that uses a checkbox to toggle between a list
Users drag rows up and down in my DataGridView. I have the dragging logic
I have a flash site that users can view full Screen video. the trouble
I created a jquery toggle, but when I click the link to open a

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.