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

The Archive Base Latest Questions

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

I have a top nav bar and some of its items trigger dropdowns/slide-downs. My

  • 0

I have a top nav bar and some of its items trigger dropdowns/slide-downs.

My problem is that whenever I click an item, or actually any area within the dropdown, the dropdown collapses.

What I need help with is figuring out how to avoid collapsing the dropdown when a child element is clicked (or well, anywhere within the dropdown area since I’d like to account for accidental clicks inside the dropdown but that are not actually clicks on a child element).

Here’s the basic HTML structure I have:

<ul class="dropdown">
 <li><a href="#" class="noclick nojs">Select your Topic</a>
  <ul class="nojs" >
    <li><a href="#">Link 1</a></li>
    <li><a href="#">Link 2</a></li>
    <li><a href="#">Link 3</a></li>
  </ul>
 </li>
</ul>

My JavaScript:

$('.dropdown li').click(function() {
  //Hide all other drop downs that are visible, and remove the class 'selected'
  $(this).siblings('.selected').removeClass('selected').find('ul:visible').slideUp('fast');

  //Show/Hide dropdowns
  $(this).toggleClass('selected');
  $('ul:first', this).stop(true, true).slideToggle('fast');
});

Here’s a DEMO

Any help is greatly appreciated.

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-06-14T22:04:55+00:00Added an answer on June 14, 2026 at 10:04 pm

    stop event.stopPropagation() on those children elements so the event doesn’t bubble up to the li

    $('ul.nojs *').click(function(e){
       e.stopPropagation(); 
    });​
    

    http://jsfiddle.net/DEfK9/

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

Sidebar

Related Questions

I have a nav bar with a drop down that is working beautifully. The
Okay so i have a nav bar on top of the webpage and on
I have a tab bar driven app. The app has some view controllers that
For my mobile-desktop nav-bar I have background buttons (default). On top I'm using :after
Using twitter bootstrap. on the site i have a top nav bar consisting of
I have a menu set up this way: <div id='top-navigation'> <ul> <li><a class='top-nav-button-unclicked' href='#'>SUBJECT</a></li>
I have a page with elements, with relative position. style=position: relative; Some have top/left
How can I have a top-and bottom margin that's at absoulute top and bottom
I'm building a SL4 app. I have two controls, a top search bar and
Basically the way my site is layed out, I have some elements that have

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.