Possible Duplicate:
Show and hide divs at a specific time interval using jQuery
I have a jQuery script what is showing and hiding divs at a specific interval. It's working fine but I have one problem, its showing and hiding divs round and round so basically its never stops. How can I make this stop? Lets say it stops after showing 3x the divs.
$(function() {
    var timer = setInterval( showDiv, 5000);    
    var counter = 0;
    function showDiv() {
        if (counter == 0) { 
            counter++; 
            return; 
        }
        $('div','#container')
            .stop()
            .hide()
            .filter( function() { return this.id.match('div' + counter); })   
            .show('fast');
        counter == 3? counter = 0 : counter++; 
    }
});
 
     
     
     
     
     
    