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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:54:54+00:00 2026-05-26T10:54:54+00:00

So, I have bunch of elements inside parent elements: <div class=copyFrom> <div class=copyThese>copyThese1</div> </div>

  • 0

So, I have bunch of elements inside parent elements:

<div class="copyFrom">
    <div class="copyThese">copyThese1</div>
</div>
<div class="copyFrom">
    <div class="copyThese">copyThese2</div>
</div>

Also, I have separate .Parent element in which I append .copyHere elements to correspond the amount of .copyFrom elements

<div class="Parent">
    <div class="copyHere"></div>
    <div class="copyHere"></div>
</div>

Aaaalso, Inside .copyHere I clone every separate .copyThese elements

<div class="Parent">
    <div class="copyHere">
        <div class="copyThese">copyThese1</div>
    </div>
    <div class="copyHere">
        <div class="copyThese">copyThese2</div>
    </div>
</div>

Now, the problem is:

For some reason, if .Parent is below all the .copyFrom elements The .copyThese elements are cloned in just fine.

But.. If .Parent element is above The .copyFrom elements, the cloning of .copyThese elements goes haywire.

I need to have .Parent element both above and below. ( Without weird cloning problems.)

jsfiddle:

http://jsfiddle.net/lollero/mZhUG/2/ – Above – Correct

http://jsfiddle.net/lollero/mZhUG/3/ – Below – Problem

  • 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-26T10:54:55+00:00Added an answer on May 26, 2026 at 10:54 am

    It is because you are adding a new .copyThese element each iteration.

    copyThese.eq( copyHere ).clone().appendTo( $(this) );

    You are cloning the nth element, but you have added n elements above, so even though your indexer is incrementing you are still cloning the same div.

    $('.copyHere').each(function(){
        var copyHere = $(this).index();
    
        // you re-initialise this array within each loop, 
        // elements are added to the start of the array each time
        var copyThese = $('.copyThese');
    
        copyThese.eq( copyHere ).clone().appendTo( $(this) );
    });
    

    change to this and it works:

    copyThese = $('.copyThese');
    
    $('.copyHere').each(function(){
        var copyHere = $(this).index();
        copyThese.eq( copyHere ).clone().appendTo( $(this) );
    });
    

    do you see the difference? I’m maybe not explaining it very well but hopefully you can see the problem.

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

Sidebar

Related Questions

I have a bunch of elements like the following: <div class=droppableP id=s-NSW style=width:78px; height:63px;
I have a bunch of <div> elements, each of which has a name .
Its the standard float issue. You have a bunch of floating elements inside a
I have a bunch of elements like this: <div></div> <span></span> <table></table> <div></div> <span></span> <div></div>
I have a bunch of elements that look like this: <span class='tags' id='html'>html</span> <span
I have a bunch of elements that look like <div id=username-2343></div> I need to
I have a UIView that contains my UIScrollView (with a bunch of elements inside)
So I have a bunch of paragraph elements which are dynamically populated from a
I have a bunch of child elements that are uniquely identified within a parent
I have a bunch of elements with <div id='id1'></div> and would like to return

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.