title: How to copy List contents inside an attribute of other Lists?
body: <p>I want to create a copy of the contents of my <em>List</em> inside an attribute of the other <em>dynamic lists</em>.</p>
  
  <p><img src="https://i.stack.imgur.com/ADXgx.png" alt="Example"></p>
  
  <hr>
  
  <p>I tried to accomplish this with jQuery and I did it as follows:</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;ul class="main"&gt;
      &lt;li&gt;Alpha&lt;/li&gt;
      &lt;li&gt;Beta&lt;/li&gt;
      &lt;li&gt;Gamma&lt;/li&gt;
      &lt;li&gt;Delta&lt;/li&gt;
  &lt;/ul&gt;
  
  &lt;ul class="clone"&gt;
      &lt;li&gt;content 1&lt;/li&gt;
      &lt;li&gt;content 2&lt;/li&gt;
      &lt;li&gt;content 3&lt;/li&gt;
      &lt;li&gt;content 4&lt;/li&gt;
  &lt;/ul&gt;
  &lt;ul class="clone"&gt;
      &lt;li&gt;content 1&lt;/li&gt;
      &lt;li&gt;content 2&lt;/li&gt;
      &lt;li&gt;content 3&lt;/li&gt;
      &lt;li&gt;content 4&lt;/li&gt;
  &lt;/ul&gt;
  [..etc..]
  </code></pre>
  
  <p>jQuery:</p>
  
  <pre><code>var Alpha = $('ul.main li:nth-child(4n+1)').text();
  var Beta = $('ul.main li:nth-child(4n+2)').text();
  var Gamma = $('ul.main li:nth-child(4n+3)').text();
  var Delta = $('ul.main li:nth-child(4n+4)').text();
  
  $('ul.clone li:nth-child(4n+1)').attr('data-content', Alpha);
  $('ul.clone li:nth-child(4n+2)').attr('data-content', Beta);
  $('ul.clone li:nth-child(4n+3)').attr('data-content', Gamma);
  $('ul.clone li:nth-child(4n+4)').attr('data-content', Delta);
  </code></pre>
  
  <p><a href="http://jsfiddle.net/bn6BF/1/" rel="nofollow noreferrer"><strong>jsFiddle</strong></a></p>
  
  <p>The problem is that I have to write for every li a <code>:nth-child()</code> so to resolve the problem I want to create a <strong>LOOP</strong> for <code>nth-child(Xn+X)</code>, because if I have 100 items in the <code>.main</code> list I want to clone this 100 items to all other <code>.clone</code> lists (that respectively have 100 items) in <code>data-content</code>.</p>
  
  <p>Is there a better way to do this dynamically instead of writing <strong><a href="http://www.w3schools.com/cssref/sel_nth-child.asp" rel="nofollow noreferrer">:nth-child(4n+1)</a></strong> for every li?</p>