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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:27:32+00:00 2026-05-16T04:27:32+00:00

I have a nested unordered list representing a tree hierarchy. There can be many

  • 0

I have a nested unordered list representing a tree hierarchy. There can be many deeply nested ul tags in the unordered list. Very simple example:

<ul>
    <li><a href="#" class="allowed">Link</a>
        <ul>
            <li><a href="#" class="allowed">Link</a></li>
            <li><a href="#" class="allowed">Link</a></li>
        </ul>
    </li>
    <li><a href="#" class="allowed">Link</a>
        <ul>
            <li><a href="#" class="disallowed">Link</a></li>
            <li><a href="#" class="disallowed">Link</a></li>
        </ul>
    </li>
</ul>

As you can see, some links can have class “allowed”. When a link like that is clicked, I would like to get a next a tag in the tree and if it has class “disallowed”, change it to “allowed”.

How can I get the next a tag in the tree?

UPDATE:

What I mean. Before:

<ul>
    <li><a href="#" class="allowed">Link</a>
        <ul>
            <li><a href="#" class="allowed">Link</a></li>
            <li><a href="#" class="allowed">Link</a></li>
        </ul>
    </li>
    <li><a href="#" class="allowed">Link</a><!-- this gets clicked on -->
        <ul>
            <li><a href="#" class="disallowed">Link</a></li>
            <li><a href="#" class="disallowed">Link</a></li>
        </ul>
    </li>
</ul>

HTML changes to this:

<ul>
    <li><a href="#" class="allowed">Link</a>
        <ul>
            <li><a href="#" class="allowed">Link</a></li>
            <li><a href="#" class="allowed">Link</a></li>
        </ul>
    </li>
    <li><a href="#" class="allowed">Link</a>
        <ul>
            <li><a href="#" class="allowed">Link</a></li>
            <li><a href="#" class="disallowed">Link</a></li>
        </ul>
    </li>
</ul>

And so 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-05-16T04:27:32+00:00Added an answer on May 16, 2026 at 4:27 am
    $('.allowed').live(function() {
        var links= $('a');
        var ix= links.index(this);
        if (ix!==-1 && ix<links.length-1)
            links.eq(ix+1).removeClass('disallowed').addClass('allowed');
    });
    
    • this uses live() to catch clicks, assuming that after after a link is changed to class="allowed", clicking that should perform the same action

    • it looks for the next link on the whole page. If you only want to check inside a particular container, use that as the parent to find links in, eg. var links= $('#myul a');, for efficiency and to prevent it affecting other page links

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

Sidebar

Related Questions

Lets say I have an unordered nested list: <ul> <li>Item a1</li> <li>Item a2</li> <li>Item
I have list items in an unordered list that when double clicked, can be
I have a nested unordered list which has main content on the left, and
I have a set of nested unordered lists that represents page navigation. The list
Is there anyway to have nested jQuery selectors. For example: if the page also
I have a unordered list nested inside of an unordered list like below: <ul
If I have deep nested unordered list and I have a reference to the
Let's say I have a nested unordered list that I would like to serialize
I have a nested unordered list populated by ajax and I am looking to
Created a very simple HTML/CSS drop down navigation using nested unordered lists. Works great

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.