title: Jquery detect the end of effect
body: <p>I created simple function for rotate divs , for this i use setTimeOut and this function tell the script the time for repit the same and go to the next , the problem in my case is i use effects in each transitions and need the callback to the function happend to the end of effect</p>
  
  <p><strong>My function :</strong></p>
  
  <pre><code>&lt;script&gt;
  function repiter(id)
  {
  
  $(".sd_"+id).show(2000).hide(1000);
  
  var npics=4;
  var ret=(id+1);
  
  
  if (ret&gt;=npics)
  {
  var ret=0;  
  }
  
  setTimeout(function(){repiter(ret);},2000)  
  
  }
  &lt;/script&gt;
  
  
  &lt;div class="sd_0" style="display:none;"&gt;Tester 1&lt;/div&gt;
  &lt;div class="sd_1" style="display:none;"&gt;Tester 2&lt;/div&gt;
  &lt;div class="sd_2" style="display:none;"&gt;Tester 3&lt;/div&gt;
  &lt;div class="sd_3" style="display:none;"&gt;Tester 4&lt;/div&gt;
  
  &lt;script&gt;
  repiter(0);
  &lt;/script&gt;
  </code></pre>
  
  <p>As you can see here , the function rotate the 4 divs and the contents , when go to the end repit the first and all time return , but in each case , the effect for each div = 4 or 5 seconds and in middle of animation of div the setTimeout call other time the function and break the effect in each case , by this my question , exists some method in jquery for setTimeout only run when effects it´s finished and after this call other time to the function ?</p>
  
  <p>Thank´s </p>