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

  • Home
  • SEARCH
  • 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 4562916
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:17:02+00:00 2026-05-21T18:17:02+00:00

Please see this Fiddle . QUESTION #1 If you click on Overview and click

  • 0

Please see this Fiddle.

QUESTION #1

If you click on “Overview” and click it again, a dropdown will be toggled/untoggled.

But if you click on “Overview” once – then click on “Per X” once – and so on, all dropdowns will remain open.

I would like to have only the most recent dropdown appear, and the prior disappear whenever the user clicks either outside the button, or clicks on another button.

QUESTION #2

This CSS (from A Shaw’s fullCalendar) has a class

fc-state-active which I would like to be inserted in the first <span> when the user activates a dropdown, replacing fc-state-default. Of course, this should only affect the clicked button.

Any help with either issue is greatly appreciated!

Thanks!

EDIT:

At this point the answer by @Demian Brecht gets very close to solving the problem – but still I can’t untoggle the dropdown menu by clicking anywhere else on the screen or by clicking the same button again.

You can see the current state of this code at http://jsfiddle.net/qEtgR/

If anyone can give me a solution to this that would be great. Thanks.

  • 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-21T18:17:03+00:00Added an answer on May 21, 2026 at 6:17 pm

    Try this for #1:

    $(".toggle").click(function(){
        $('#nav ul:visible').toggle();
      $('ul',this).toggle();
    });
    

    Edit: (reworked for completion)

    var cur = null;
    $(".toggle").click(function(){
        $('#nav ul:visible').toggle();
        console.log();
        if(cur != null)
        {
            cur.removeClass('fc-state-active').addClass('fc-state-default');
        }
        cur = $(this).children('a:first').children('span').removeClass('fc-state-default').addClass('fc-state-active');
        $('ul',this).toggle();
    });
    

    Fiddle here

    I cache the currently selected menu element here to avoid a global selector (and additional overhead).

    Edit:

    So, here’s what I’ve come up with (sorry, woulda been sooner, but was away):

    var cur = null;
    $(".toggle").click(function(e){
        $('#nav ul:visible').hide();
    
        if(cur == null || cur.currentTarget != e.currentTarget)
        {
            if(cur != null)
            {
                $(cur.currentTarget)
                    .removeClass('fc-state-active')
                    .addClass('fc-state-default');
            }
    
            cur = e;
            $(cur.currentTarget)
                .removeClass('fc-state-default')
                .addClass('fc-state-active')
                .children('ul')
                .show();
        }
        else
        {
            $(cur.currentTarget)
                .removeClass('fc-state-active')
                .addClass('fc-state-default');
    
            cur = null;
        }
    });
    
    $('body').children().not('ul#nav').click(function(e){
        $('#nav ul:visible').hide();
    
        $(cur.currentTarget)
                .removeClass('fc-state-active')
                .addClass('fc-state-default');
    
        cur = null;
    });
    

    You can check out the update at the same fiddle URL. The caveat to this update is that a user needs to click on anywhere on the page that contains something (the base selector is body). Couldn’t figure out a nice selector for anywhere other than the nav element (probably nested somewhere in the children of the document object), but I’m too tired to dig anymore 🙂

    Oh, and I wasn’t happy with the structure of the last update, so I just re-wrote it 😛

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

Sidebar

Related Questions

Please see this fiddle and click decrease: http://jsfiddle.net/2C8fy/16/ As you can see the images
Please see this fiddle I want the scrolling div stop following when left div
Important : Please see this very much related question: Return multiple values in C++
Please see this image: I need something like this which will show quote's gradually
Please see this fiddle for my situation. Essentially, I have a floating span which
Please see this fiddle (the result window should be made large). When one of
This is my code (please see this fiddle ): HTML <div id=container> <span id=left>Left
Note: This question was marked as solved once, but it figured out that upgrading
Please see this question for background information: How do Tasks in the Task Parallel
Please take a look at this fiddle: http://jsfiddle.net/hughbe/QYGcq/ As you can see, the label

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.