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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:54:04+00:00 2026-05-26T09:54:04+00:00

My problem is that I only want Header 1 and Header 2 to call

  • 0

My problem is that I only want Header 1 and Header 2 to call the click function. If i click on List item 1.1 etc I want nothing to happen. As it is now, clicking on any list item will call the event.

Javascript

$(document).ready(function() {
    $("ul#nav li ul").hide(); 
    $("ul#nav li").click(function() {
        $("ul#nav li").removeClass("current"); 
        $(this).addClass("current"); 
        $("ul#nav li ul").slideUp('fast'); 
        $(this).find("ul").slideDown('fast');
    });
});

HTML

    <ul id="nav">  
        <li><a href="#">Header 1</a>
        <ul>
           <li>List item 1.1</li>
           <li>List item 1.2</li>
           <li>List item 1.3</li>
        </ul>
        </li>
       <li><a href="#">Header 2</a>
       <ul>
           <li>List item 2.1</li>
           <li>List item 2.2</li>
           <li>List item 2.3</li>
       </ul>
       </li>
    </ul>

I have looked through a couple of similar questions and answers but they did not quite help me to solve the problem.

  • 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-26T09:54:05+00:00Added an answer on May 26, 2026 at 9:54 am

    Here’s how I would do it:

    $( nav ).delegate( 'li', 'click', function () {   
        if ( !$( this ).parent().is( nav ) ) { return false; }  
        $( this ).siblings( '.' + clss ).removeClass( clss ).children( 'ul' ).slideUp( 'fast' );
        $( this ).addClass( clss ).children( 'ul' ).slideDown( 'fast' )
    });
    

    Live demo: http://jsfiddle.net/WsZdJ/4/

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

Sidebar

Related Questions

My problem is that I can only seem to click the button once, if
I've got an app that's in invite-only beta right now. Problem is, I can't
I have a strange problem that is only happening in a single location. I
Possible Duplicates: Is there a problem that has only a recursive solution? Can every
I have the problem that an specific step in Ant can only be executed
Ok, my problem is that some providers support SREG and some support only AX
I like using LINQ to SQL. The only problem is that I don't like
I have a problem with jquery and a dynamic table. I want a click
I am having that problem that I got some items on a list that
Hope the title was OK. My problem is that I want to generate an

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.