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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:06:06+00:00 2026-05-29T11:06:06+00:00

I have three lists. When I click next I want to get the next

  • 0

I have three lists.
When I click next I want to get the next li, which is fine but when I reach the end of the first list I would like the next to be the first of the second list.. I’ll try and explain a little better.

<ul class='list'>
   <li image_id="1"></li>
   <li image_id="2"></li>
</ul>

<ul class='list'>
   <li image_id="3"></li>
   <li image_id="4"></li>
</ul>

<ul class='list'>
   <li image_id="5"></li>
   <li image_id="6"></li>
</ul>

So I have three lists.. next I want to know how many li’s I have so I wrote..

var how_many $('ul.list li').length;

this is good, it’s bringing back all 6 li’s..

next I want to find a li if it has the image id im currently on.

var which = $('ul.list li[image_id^="' +  image_id +'"]');

all works fine at this point.

so now Im going to find what the next li’s image id is..

var found_next = which.nextAll('ul.list li').attr('image_id');

this also works..

I then load the new image in using a .load that has a callback that updates the current image_id…

The “PROBLEM” is when click, next..next..next etc and I get to the end of say the first list jquery brings back “undefined” not the first li of the second list. has anyone got any suggestions?

Any help would be much appreciated.

  • 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-29T11:06:07+00:00Added an answer on May 29, 2026 at 11:06 am

    .nextAll only works for siblings. If you want to jump to the next <li>, you have to select all elements, and use .index and .eq() to select the next <li>.

    var $li = $('ul.list li');
    // Example, inside an event listener:
        var index = $(this).index($li);
        var nextElement = $li.eq( index + 1 );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three lists that I want to convert into one list. When I
I have a nested list comprising ~30,000 sub-lists, each with three entries, e.g., nested_list
I have a list of MyObjects which I need to divide into three groups:
I have three lists of lists, and I'm trying to write a generator function
Suppose I have three lists: list1 = a, c, d, r, t list2 =
So I currently have three unordered lists in my header. This is a single-page
I have three cascaded drop down lists. ddlIllnessType, ddlIllnessSubType and ddlInfectiousAgent Initially, only ddlIllnessType
I have a list of strings in kumo . I am printing three strings.
I have kept the object into a list. I want to iterate them with
I have got a list of Music Titles in a ListView. I can click

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.