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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:20:18+00:00 2026-06-13T16:20:18+00:00

I was wondering how to achieve something like this using jQuery: <ul> <li><a href=#id-220

  • 0

I was wondering how to achieve something like this using jQuery:

<ul>
    <li><a href="#id-220" class="id-220 id-320 id-321 id-322">Nunc tincidunt</a></li>
    <li><a href="#id-320" class="id-320 id-321 id-322">Proin dolor</a></li>
    <li><a href="#id-321" class="id-321 id-322">Aenean lacinia</a></li>
    <li><a href="#id-322" class="id-322">Aenean lacinia</a></li>
</ul>

If I have only this:

<ul>
    <li><a href="#id-220">Nunc tincidunt</a></li>
    <li><a href="#id-320">Proin dolor</a></li>
    <li><a href="#id-321">Aenean lacinia</a></li>
    <li><a href="#id-322">Aenean lacinia</a></li>
</ul>

So, basically I want that each list item is looking for its sibling’s ID and add them by order as class. First list item has 3 siblings, and by that it must have 4 classes (his own and 3 from siblings) and so on … I hope that I explained it well… TNX!

  • 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-06-13T16:20:20+00:00Added an answer on June 13, 2026 at 4:20 pm

    Try this

    <ul id="mainUL">
            <li><a href="#id-220">Nunc tincidunt</a></li>
            <li><a href="#id-320">Proin dolor</a></li>
            <li><a href="#id-321">Aenean lacinia</a></li>
            <li><a href="#id-322">Aenean lacinia</a></li>
    </ul>
    
    
    <script type="text/javascript">
            var As = $("#mainUL").find("a");
            for (var i = 0; i < As.length; i++) {
                var curAi = $(As[i]);
                var clas = curAi.attr("href").replace("#", "");
                for (var j = i; j < As.length; j++) {
                    var curAj = $(As[j]);
                    clas += " " + curAj.attr("href").replace("#", "");
                }
                curAi.addClass(clas);
            }
    
    </script>
    

    I know there could be more efficient and better solutions too. But this one is running fine for me without any bug, Worth a try.

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

Sidebar

Related Questions

I am wondering if it's possible to achieve this using the jQuery UI Slider.
I was wondering if it's possible to write something like this: <Window ... xmlns
Wondering what the best / good way of doing this would be in jQuery.
The effect I wanted to achieve is something like the Mail icon in iPhone.
bit stuck try to achieve something in Jquery and wondered if anyone can assist..
What's the best way to achieve something like code folding, or the type of
When I do something like this: $boards = Doctrine_Query::create() ->select('bds.id') ->from('board bds') ->whereIn('bds.type', $boardtype)
I was wondering how to achieve the effect found at : http://thekitchencommunity.com/ in the
I was wondering how to achieve the following in python: for( int i =
I was wondering if it's possible to achieve that in CSS 2/3 (or if

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.