title: Loop through all elements in each container
body: <p>I need to loop through all items in each container, starting from 1 every time the loops reaches a new container. </p>
  
  <p>Edit: added JSFiddle <a href="http://jsfiddle.net/ntv4k4LL/" rel="nofollow">http://jsfiddle.net/ntv4k4LL/</a></p>
  
  <p>E.g.</p>
  
  <pre><code>Container
  
   - 1 
   - 2
   - 3
  
  Container
  
   - 1 
   - 2
   - 3
  </code></pre>
  
  <p>But at the moment it's going</p>
  
  <pre><code>Container
  
   - 1 
   - 2
   - 3
  
  Container
  
   - 4 
   - 5
   - 6
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>$('.index-slide-rel').each(function(){
  
       $(this).children('article').each(function(i,e){
  
           col++;
  
           if(i &gt; 0 &amp;&amp; i%cols === cols-1) {
               sx= 0;
               row++;
               col=1;
               sy += previewElementHeight;
           }                  
       })                     
  });
  </code></pre>