trigger('click') inside setInterval()
<p>i have this code:</p>

<pre><code>setInterval(function() {
    $('.button2').trigger('click');
    $('.button3').trigger('click');
}, 5000);
</code></pre>

<p>result:</p>

<p>it presses .button2 and .button3 at the same time every 5 seconds. I need something like this - 5 seconds passed press .button2, 5 seconds passed press .button3, need a delay between each button clicks and when .button3 is pressed - again press .button2 (something like a loop).</p>

<p>Any help would be appreciated!</p>

<p>EDIT for flesk:</p>

<pre><code>$(document).ready(function (){
    $('.goluboi a').click(function(){
        var integer = $(this).attr('rel');
        $('.videos .cover').animate({left:-875*(parseInt(integer)-1)})  /*----- Width of div mystuff (here 160) ------ */
        $('.goluboi a').each(function(){
        $(this).removeClass('active');
            if($(this).hasClass('button'+integer)){
                $(this).addClass('active')}
        });
    });

    setTimeout(function() {
        triggerClick('.button', 0)
    }, 5000);
    function triggerClick(selector, index) {
        var buttons = $(selector);
        var mod = index++ % buttons.length;
        $(buttons[mod]).trigger('click');
        setTimeout(function() {
            triggerClick(selector, index);
        }, 5000);
    }
});
</code></pre>
