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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:41:12+00:00 2026-05-15T20:41:12+00:00

I just got a fix on another post I just made but this created

  • 0

I just got a fix on another post I just made but this created a nother problem. I am working on a navigation menu with multiple levels. Here is the script I am using:

$(document).ready(function(){

// attach the click handler for the menu
$(".left-navigation-holder li a[href='']:has(~ul)").click(toggleMenu);

// Expand menu for the current page:
var level1Selector = "#" + $("body").attr("menul1");
var level2Selector = "#" + $("body").attr("menul2");
var level3Selector = "#" + $("body").attr("menul3");

 $(".left-navigation-holder li a:has(~ul"+ level1Selector +")").click();
 $(".left-navigation-holder li a:has(~ul"+ level2Selector +")").click();
 $(".left-navigation-holder li a:has(~ul"+ level3Selector +")").click();

});

// menu toggle function
function toggleMenu() {
//if ($(this).attr(href='#')) {alert("yes")} else {alert("no")}
$(this).siblings("ul").toggle();
$(this).closest("li").toggleClass("selected");


 return false;
}

The first line initiate the menu by saying that if there is a click event on one link in the menu and if that link has an empty href attribute and a list further down, then it fires toggleMenu to open that level. The reason for checking for the value of href is that if is empty, the menu opens, if not it sends the user to the URL value and does not toggle the menu. That leaves the option to have a page link for some menus (and keep sub-levels) when other are just here to toggle the sub menu.

The other part of the script reads the values of the attributes I have set in the body tag on each page (menul1, menul2, menul3) to know on what page in the menu we are so the menu opens the right menu levels when the page loads.

The problem I have is that because the first line checks for the value of the href attribute, if the page loaded was called by clicking a menu that had a link and a sub menu, that one does not open when loading the page because the href has a value. The 3 lines that were initiating each levels now only work when the href value is empty.

Not sure what to do. Help would be appreciated. I hope this was clear enough.

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-05-15T20:41:13+00:00Added an answer on May 15, 2026 at 8:41 pm

    You seem to want to do two different things in the same way – you want to disable toggling a menu with a link by clicking it, but then you try to open it by clicking it as well.

    Rather than call click() to open each of the menus for the current page, could you not just call toggleMenu instead?

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

Sidebar

Related Questions

Just got a request from my boss for an application I'm working on. Basically
Just got a question about generics, why doesn't this compile when using a generic
I just got done working through the Django tutorials for the second time, and
I just got this error message: ... from c:/ruby/lib/ruby/gems/1.8/gems/... ... 10 levels... from c:/ruby/lib/ruby/gems/1.8/gems/...
In a sort of follow up to this question , I have another problem
i've got this problem again... So i've got String data in my Struts2 app.
I just got Delphi 2009 and have previously read some articles about modifications that
I just got a dedicated server from a hosting company, and for some reason,
I just got through manually removing the bin\ and obj\ folders from around 30
I just got a shiny, brand-new Debian server handed to me by our Systems

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.