FadeIn, FadeOut then do the same with another image
<p>I want to fadeIn image, wait few msec and fadeOut image and I want to do this with few images, I also want to loop this. My idea was to do this with for each loop, but it doesn't work. I wrote this:</p>

<pre><code>function showDiv() {
    if($('.header_img a:not(:contains(shown))').length) {
        var current = ($('.header_img a:not(:contains(shown)):first'));
        $(current).fadeIn(1500).delay(4000).fadeOut(1500);
        $(current).addClass('shown');
        setTimeout(showDiv, 1000);
    }
}
showDiv();
</code></pre>

<p>Edit:
A lot of thanks for all the answers :) However, I've made something on my own:</p>

<pre><code>  $(document).ready(function(){
     var current = ($('.header_img a:first-child'));    
    var counter = 0;
 var n = $(".header_img a").length;
function showDiv(current) {
    if(counter&lt;n-1 )
    {
    counter++;
    $(current).fadeIn(1500).delay(4000).fadeOut(1500, function(){
    current=$(current).next();
    showDiv(current);
    })
}
else{
counter = 0;
$(current).fadeIn(1500).delay(4000).fadeOut(1500, function(){
    current=($('.header_img a:first-child'));   
    showDiv(current);
    })
}

  }
showDiv(current);
  });
</code></pre>

<p>... and it works!</p>
