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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:58:54+00:00 2026-05-27T22:58:54+00:00

I have the following simple 3 level menu structure: <nav class=main-nav class=list> <ul> <li

  • 0

I have the following simple 3 level menu structure:

<nav class="main-nav" class="list">
  <ul>
    <li class="first lev1"><a href="">Home</a></li>        
    <li class="lev1"><a href="">Lev 1 1</a></li>
    <li class="lev1 hasc active">
      <a href="">Lev 1 2</a>
      <ul>
        <li class="first lev2 hasc">
          <a href="">Lev 2 1</a>        
          <ul>
            <li class="first lev3"><a href=""></a>Lev 3 1 </li>
            <li class="lev3"><a href="">Lev 3 2</a></li>
          </ul>
        </li>
      </ul>
    </li>
    <li class="lev1 hasc active"><a href="">Lev 1 3</a></li>
  </ul>
</nav>

I’m trying to make the menu work so that the second level menu slides open when it has children but is an active link when it does not and then all 3rd level links are always active links.

The following jquery code works for all the required functionality for the 2nd level menu (prevents default and opens the 3rd level if there are children, but if not makes the link active) the problem is that i’m not sure how to over ride the prevent default for the third level?

$(".lev2").click(function (event) {
    event.preventDefault();
    if ($(this).hasClass('on')) {
        $(this).children('ul').slideUp();
        $(this).removeClass('on');
    } else {
        $(this).children('ul').slideDown();
        $(this).addClass('on');
    }
});

I’ve looked into starting at the root of the menu class ‘main-nav’ and then try to branch the code but as it is nested I’m not finding any logic that will work? any ideas most welcome.

  • 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-27T22:58:54+00:00Added an answer on May 27, 2026 at 10:58 pm

    This works. Just checks for a level 3 click first to tell the level 2 function whether level 3 has been clicked or not.

    $(document).ready(function(){
        var level2 = true;
        $("li.lev3").click(function(){
            level2 = false;
        });
        $("li.lev2").click( function(event){
            if (level2){
                alert ("lvl2");
                event.preventDefault();
                if($(this).hasClass('on')) {
                    $(this).children('ul').slideUp();
                    $(this).removeClass('on');
                }else{
                    $(this).children('ul').slideDown(); 
                    $(this).addClass('on');   
                }
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following simple class: @interface Article: NSObject { NSString *title; } @property (copy,
I have the following simple Java code: package testj; import java.util.*; public class Query<T>
i have the following simple script <input class=input type=text name=password style=color: #797272; value= <?php
Excuse the beginner level of this question. I have the following simple code, but
Simple question. I have the following HTML: <a rel=nofollow id=claim-job-link data-method=post class=button green claim-job
Let's say I have this simple structure class FooDefinition { public FooDefinition Parent {
I have the following: class Menu < ActiveRecord::Base has_many :menu_headers # has_many :menu_headers, :conditions
We have the following simple Stored Procedure that runs as an overnight SQL server
I have the following simple button with an image as the template. The problem
I have the following simple function: private void EnableDisable941ScheduleBButton() { if (this._uosDepositorFrequency.Value != null)

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.