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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:21:38+00:00 2026-06-05T16:21:38+00:00

$(function(){ $(li.level2).hide(); $(li.level3).hide(); $(ul.navigation).delegate(li.level1, click, function() { $(li.level2).toggle().siblings(li.level3).hide();; }); $(ul.navigation).delegate(li.level2, click, function() { $(li.level3).toggle();

  • 0
$(function(){
    $("li.level2").hide();
    $("li.level3").hide();

    $("ul.navigation").delegate("li.level1", "click", function() {
        $("li.level2").toggle().siblings("li.level3").hide();;
    });

    $("ul.navigation").delegate("li.level2", "click", function() {
        $("li.level3").toggle();
    });
});

I’m using this script to make a drop down menu for my page in jquery, but currently when you click on a level1 list it opens up every level1, when i just want to open the one that was clicked on. ie. it is doing this when i click on the first 1:

1

    2

1

    2

when i want it to do this

1

    2

1

I understand you can use the $this function to only open the one selected, but i am unsure how to implement it and whenever i try (this).next it only opens the next one when

I included an active page with styling to make it easier to interpret: http://jsfiddle.net/K6TSv/1045/

thanks for your help in advanced, this has been driving my head on.

  • 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-05T16:21:40+00:00Added an answer on June 5, 2026 at 4:21 pm

    get the clicked item using $(this) and then get the next level2 items and show that.

    $("ul.navigation").delegate("li.level1", "click", function() {
        var item=$(this);
        item.next(".level2").toggle();      
    });
    

    jsfiddle Sample : http://jsfiddle.net/K6TSv/1046/

    If i were doing this. I would create a hierarchical HTML markup to handle this which will make things easy

    EDIT : As per the comment ( Markup changed!!!)

    If you want to select elements based on some selection criteria unitl some element, Use nextUntil function.

    $(this).nextUntil(".level1",".level2").toggle();
    

    Sample http://jsfiddle.net/K6TSv/1072/

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

Sidebar

Related Questions

I am using this jQuery menu script: (function($) { $.fn.blowfish = function() { //
Here's my function to load my content: $(#site-nav .nav1).on('click', function () { $(this).addClass(nav-active); $('ul.top-level').load('assets/includes/recent.php',
How to make Keyboard navigation left/up/right/down (like for photo gallery) feature for jQuery Tabs
So I made this super stripped down version of a html css jquery navigation
I'm using a showhide script that I've altered in order to enable it for
I have this script for my CSS Vertical Menu: //Nested Side Bar Menu (Mar
I am using a Jquery Toggle sidebar menu, so there is a down arrow
I'm trying to put together a navigation menu that uses click instead of hover
I am having a problem with this function. I cannot get it to fire
Can anyone please why does this javascript work only in firefox? function filter(obj, what,

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.