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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:14:29+00:00 2026-06-11T22:14:29+00:00

I am trying to make a drop down menu and want all other open

  • 0

I am trying to make a drop down menu and want all other open menus to have a class removed when a different menu appears. the problem is, is that you have to click twice on a menu you previously clicked on to get it to open again:

$(document).ready(function(){
$('li.dropdown').click(function(){
    //$('.dropdownmenu').hide() ;
    $('.dropdownmenu').not('ul', this).removeClass('opened');
    if($(' ul', this).hasClass('opened'))
    {
        $(' ul', this).removeClass('opened');
        $(' ul', this).hide();
    }
    else
    {
        $(' ul', this).addClass('opened') ;
        $(' ul', this).show() ;
    }

})
})

Here it is in JSFiddle, click on the Item text to make the menus pop up, if you open and close a few the problem will become apparent. If you know a better way of doing what I’m trying to achieve please let me know!

And yes you can if you like 😛 she’s my favourite haha


Also, the menu should close if you click on the menu item again.

  • 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-11T22:14:30+00:00Added an answer on June 11, 2026 at 10:14 pm

    When I need to do this I usually remove the class from everything, without worrying about the one that should keep it, same with hiding the element.

    Then simply add the necessary class to the clicked on element and show it.

    If you do need to do not, then do:

    var ul = $(this).closest('ul');
    

    and then use the variable in not().

    You actually have things reversed – you are looking for a ul inside an li, which is the opposite of what it should be.

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

Sidebar

Related Questions

I'm trying to make a drop down menu using javascript/jquery but can't get my
I'm trying to find/make a good jquery drop-down menu with animation (fadein/fadeout or slidedown)
I am trying to make a form using two drop down select menus: one
I am trying to make drop down menu. Some folks helped me on CSS
I am trying to make CSS drop down menu (no javascript involved). According to
I am trying to make a drop down menu of links. I use the
I'm trying to make a simple CSS drop down menu that when you mouse
I am trying to make the drop down menu lists display inline(horizontally) but end
im trying to make an easy drop down menu plugin for jquery but for
I'm trying to make this jquery drop down bar be on top at all

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.