title: Restart jQuery.each() after loop ends
body: <p>I have array of values and i want to set those values as placeholders to my input.</p>
  
  <p>How to achieve this using <code>jQuery.each()</code> <strong>only</strong> because i solved my issue with  <a href="https://stackoverflow.com/questions/6051471/jquery-infinite-loop-through-array-each">this solution</a> and it works perfectly.</p>
  
  <p>I tried doing this to restart it but it's not working:</p>
  
  <pre><code>if(index==arr.length) index=0;
  </code></pre>
  
  <p><strong>HTML code:</strong></p>
  
  <pre><code> Values : &lt;input name='input' id='input' /&gt;
  </code></pre>
  
  <p><strong>JS/jQuery code:</strong></p>
  
  <pre><code>var arr = new Array();
  for (var i = 0; i &lt;= 5; i++) {
      arr.push('Value ' + i);//fill array with values
  }
  
  function eachChange(){
     var x=0;
     $.each(arr, function (index, value) {
         x++;
     setTimeout(function(){ 
         $('input').attr('placeholder', value);
        }, x * 1000); 
         if(index==arr.length) index=0;
  
   });   
  
  }
  eachChange();//call function
  </code></pre>
  
  <p><strong>Fiddle:</strong>  <a href="http://jsfiddle.net/charaf11/5ZQgX/" rel="nofollow noreferrer">http://jsfiddle.net/charaf11/5ZQgX/</a></p>