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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:31:13+00:00 2026-05-24T03:31:13+00:00

I have a series of DIV elements with more DIV elements inside of them,

  • 0

I have a series of DIV elements with more DIV elements inside of them, of variable lengths. As example code to simplify the matter…

<div class="container">
 <div class="inset"></div>
 <div class="inset"></div>
 <div class="inset"></div>
 <div class="inset"></div>
 <div class="inset"></div>
</div>
<div class="container">
 <div class="inset"></div>
 <div class="inset"></div>
 <div class="inset"></div>
 <div class="inset"></div>
 <div class="inset"></div>
 <div class="inset"></div>
</div>
<div class="container">
 <div class="inset"></div>
 <div class="inset"></div>
 <div class="inset"></div>
</div>

I have been using jQuery’s each() to move between the “inset” DIVs. However, I’ve come to the realization I’m going to have to move between the first inset DIV in the first container, to the first in the second container, to the first in the third, then to the second in the first container, and so forth.

The problem is, I have no idea how to do this.

If it helps, the main purpose for moving these is to change their background colors in a preset pattern. I do not believe it’s possible to redo the structure of the code.

Is there any way this can be done?

  • 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-24T03:31:14+00:00Added an answer on May 24, 2026 at 3:31 am

    It can, though my approach is not the most elegant.

    Here’s a sample (need to have Firebug installed to see the output): http://jsfiddle.net/ceZkr/

    var maxlength = 0; // first need to find container with the most insets.
    $('.container').each(function(index, val){
        var curlength = $(this).find('.inset').length;
        if(curlength > maxlength) {
            maxlength = curlength;
        }
    });
    
    console.log('our maxlength: ' + maxlength);
    
    for(var i = 0;i<maxlength; i++) {
        $('.container').each(function(){
            var $box = $(this).find('.inset:eq('+i+')');
            if($box.length) {
                console.log( $box.text() );
            }
    
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a series of <div class=clear-both></div> after a series of divs. I want
I have a series of divs like this: <div id=available-posts> <div class=post id=unique_id> <a
I have a series of boxes: <div class=box></div> <div class=box></div> <div class=box></div> <div class=box></div>
I have a series of divs: <div class=some_class active>Some Content</div> <div class=some_class>Different Content</div> <div
I have a series of divs like this: <div id=listofstuff> <div id=anitem> <span class=itemname>Item1</h3></span>
I have a series of div elements on my page which look like the
I have a series of input elements each with a few <div> tags separate.
I have a series of links nested within a div. When one of those
I have a set of checkboxes setup in a series of div fieldcontain +
I have a series of buttons. Lets call them A, B, C. I attached

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.