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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:10:44+00:00 2026-05-31T18:10:44+00:00

My tree menu is in an unordered list. The links in it however don’t

  • 0

My tree menu is in an unordered list. The links in it however don’t work, I think because the whole ul listens to the jquery script. I want the links to be navigationable, can anybody tell me how to do this?

jquery:

   $("#treeMenu li").toggle(

function() {
    $(this).children('ul').slideDown()
    if ($(this).hasClass('contentContainer')) {
        $(this).removeClass('contentContainer').addClass('contentViewing');
    }
}, function() {
    $(this).children('ul').slideUp()
    if ($(this).hasClass('contentViewing')) {
        $(this).removeClass('contentViewing').addClass('contentContainer');
    }
});

html:

<ul id="treeMenu">
    <li class="folder1"> folder1
        <ul style="display: none">
            <li class="contentContainer"><a href="http://www.google.com">1.1</a></li>

            <li class="contentContainer"><a href="http://www.google.com">1.2</a></li>

            <li class="contentContainer"><a href="http://www.google.com">1.3</a></li>

            <li class="contentContainer"><a href="http://www.google.com">1.4</a></li>

</ul>

jsfiddle

  • 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-31T18:10:45+00:00Added an answer on May 31, 2026 at 6:10 pm

    From the documentation on .toggle (event):

    Since .toggle() internally uses a click handler to do its work, we must unbind click to remove a behavior attached with .toggle(), so other click handlers can be caught in the crossfire. The implementation also calls .preventDefault() on the event, so links will not be followed and buttons will not be clicked if .toggle() has been called on the element.

    Looks like that’s what’s happening to you. You can add the click functionality back in with a couple of lines of jQuery:

    $('a').click(function() {
        location.href = $(this).attr('href');
    });​
    

    (This won’t work in the fiddle, but it should work on your site.)

    However, I don’t like the way .toggle silently cancels out other click events, and it might surprise you again down the road, so I would replace your .toggle with a proper .click and use .slideToggle instead:

    $("#treeMenu li").click(function() {
        $(this).children('ul').slideToggle();
        if ($(this).hasClass('contentContainer')) {
            $(this).removeClass('contentContainer').addClass('contentViewing');
        } else if ($(this).hasClass('contentViewing')) {
            $(this).removeClass('contentViewing').addClass('contentContainer');
        };
    });​
    

    You might also use .toggleClass inside the click handler to shorten your code, but I can’t be sure of how you want classes to be added or removed based on your fiddle.

    http://jsfiddle.net/Kukd2/6/

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

Sidebar

Related Questions

I want walk back up the tree menu of a nested unordered list to
How can I find out which node in a tree list the context menu
I am using this jQuery menu script: (function($) { $.fn.blowfish = function() { //
I'm trying to use jquery cookies to store the state of a tree menu
I want to hide all the descendents of the ul for my tree menu
I am trying to build a dynamically generated unordered list in the following format
I need a tree menu. But instead of a listview where you expand/collapse i
I am using jstree to build a tree menu. When you select an item
I need to create a menu tree using HTML. I had a search on
I want to generate a tree-based menu using Java that will appear on a

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.