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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:14:22+00:00 2026-05-27T21:14:22+00:00

I have this drop down menu that when one menu is clicked if there

  • 0

I have this drop down menu that when one menu is clicked if there was another one active, this one is deactivated and then the new one is activated:

$('.idiomas span.current').toggle(function(){
   //alert(true);
   $('.idiomas span.clicked').next('ul').hide();
   $('.idiomas span.clicked').removeClass('clicked');
   $(this).next('ul').fadeIn();
   $(this).addClass('clicked');
 },
 function() {
   $(this).next('ul').hide();
   $('.idiomas span.current:not(.clicked)').show();   
 });

Ok, until here is working fine, but then I wanted the menus to be hidden when user clicks outside the entire menu; figured out that on body click should work as I needed:

 $('body').bind('click', function(e) {
   if($(e.target).closest('.idiomas ul').length == 0) {
     // se ha clickado fuera del menu
     $('.idiomas ul').hide();
     $('.idiomas span.current').removeClass('clicked').show();
     $('.facebook').css('visibility','visible');
   } else {
     // dentro: no hacemos nada.
   }
 });

and it does hide, but I need to click twice in the next menu item to make its sub-menu visible,

Any idea why?

  • 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-27T21:14:23+00:00Added an answer on May 27, 2026 at 9:14 pm

    Here’s something that might help. Here is the JSFiddle for it: http://jsfiddle.net/aTqP5/

    Basic gist to your problem is that toggle has 2 states, and when you click on the body, the element gets hidden but the toggle state is still in “show” and has to go to “hide” then back to “show” again, hence the clicking twice.

    $(document).ready(function(){    
        $('.idiomas span.current').click(function(event){
            event.stopPropagation();
            if ( $(this).hasClass('clicked') ) {
                $(this).removeClass('clicked');
                $(this).siblings('ul').hide();
            } else {
                $('.idiomas span.clicked').removeClass('clicked').siblings('ul').hide();
                $(this).addClass('clicked');
                $(this).siblings('ul').fadeIn();
            }
        });
    
        $('body').click(function(event) {
            event.stopPropagation();
            if ( $('.idiomas span.clicked').length > 0 ) {
                $('.idiomas ul').hide();
                $('.idiomas span.current').removeClass('clicked');
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, basically I have this select / drop down menu that I use AJAX
This would be my issue I have a drop down that's not displaying fully.
I have a link that functions similar to a drop down menu in that
I have a drop down menu that I am dynamically populating based on values
I have a dialog box with a drop down menu like this: Object[] possibilities
I have a drop down like this on my page: <p> <%= f.label :episode_id
I'm trying to incorporate this yui drop down menu control in a web page:
I am trying to build a drop-down menu that will show a row to
Background: I have a dropdown menu that basically works the same as the one
I have two drop down menus, one of which I am trying to replace

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.