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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:40:09+00:00 2026-05-13T23:40:09+00:00

I have two unordered lists, a bit like: <ul class=list1> <li>Item 1</li> <li>Item 2</li>

  • 0

I have two unordered lists, a bit like:

<ul class="list1">
    <li>Item 1</li>
    <li>Item 2</li>
    <li>Item 3</li>
    <li class="current">Item 4</li>
    <li>Item 5</li>
</ul>

<ul class="list2">
    <li>Item 1</li>
    <li>Item 2</li>
    <li>Item 3</li>
    <li>Item 4</li>
    <li>Item 5</li>
</ul>

And the goal is, with jquery, to identify which li is marked with the ‘current’ class and then add a class to the second list to the corresponding li. I just can’t think of how to do this.

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-13T23:40:10+00:00Added an answer on May 13, 2026 at 11:40 pm
    $('ul.list2 li:nth-child(' + $('ul.list1 li.current').index() + ')').addClass('current');
    

    Or you could make it a little less icky:

    $('ul.list2 li').eq($('ul.list1 li.current').index()).addClass('current');
    

    The second one, I like better, now that I get to see them both 🙂 The tricks here are:

    1. the “eq” filter lets you pick an element from a jQuery list based on an index;
    2. the “index” function lets you find the index of an element relative to its siblings in the DOM
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At the moment I have two (maybe more) unordered lists which are sortable with
I have two or more unordered lists with the first list item in each
I have two classes (MVC view model) which inherits from one abstract base class.
I have two list. An unordered list and a set of divs which are
I have a div with two unordered lists within it. Using Firebug the height
I have two things. have my last list item absolute bottom of my unordered
I have two divs sr-left-checks and sr-right-checks. they both contain unordered lists. The left
Say I have an unordered list, like so: <ul> <li>One</li> <li>Two</li> <li>Three</li> <li>Four</li> <li>Five</li>
I have multiple list items in an unordered list. Each list item looks like
I have two lists: ordered = ['salat', 'baguette', 'burger', 'pizza'] unordered = ['pizza', 'burger']

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.