Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6784041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:56:32+00:00 2026-05-26T16:56:32+00:00

i have this code: setInterval(function() { $(‘.button2’).trigger(‘click’); $(‘.button3’).trigger(‘click’); }, 5000); result: it presses .button2

  • 0

i have this code:

setInterval(function() {
    $('.button2').trigger('click');
    $('.button3').trigger('click');
}, 5000);

result:

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).

Any help would be appreciated!

EDIT for flesk:

$(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);
    }
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:56:33+00:00Added an answer on May 26, 2026 at 4:56 pm

    You could do:

    setTimeout(function() {
        triggerClick('.button2');
    }, 5000);
    
    function triggerClick(selector) {
        $(selector).trigger('click');
        selector = (selector == '.button2') ? '.button3' : '.button2';
        setTimeout(function() {
            triggerClick(selector);
        }, 5000);
    }
    

    EDIT: Answer to your comment below:

    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);
    }
    

    Works for any number of buttons, as long as they all have the same class. There’s no need to call them ‘button1’, ‘button2’ and ‘button3’ anyway. That’s what id’s are for.

    EDIT2:

    If I understand your update correctly, what you want is:

    setTimeout(function() {
        triggerClick('.goluboi a.button', 0)
    }, 5000);
    function triggerClick(selector, index) {
        var buttons = $(selector);
    
        // Your logic
        var integer = $(this).attr('rel');
        $('.videos .cover').animate({left:-875*(parseInt(integer)-1)})
        $(buttons).removeClass('active');
    
        var mod = index++ % buttons.length;
    
        $(buttons[mod]).addClass('active').trigger('click');
        setTimeout(function() {
            triggerClick(selector, index);
        }, 5000);
    }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem. I have this code: setInterval(function() { $.ajax({ url: url, success:
I have this jquery code: $('#fr_tab').click(function() { $(#tab2).empty().html('<img src=images/loading.gif />'); var handle = setInterval(function
I have this code window.onload = function() { function foo() { alert(test); } setInterval(foo(),500)
I have this code while($row = mysql_fetch_row($result)) { echo '<tr>'; $pk = $row[0]['ARTICLE_NO']; foreach($row
I have the following jquery code: $(.rotateNews).load(/load_news.php); var refreshId = setInterval(function() { $(.rotateNews).load('/load_news.php?newsID='); },
I have this banner rotator code: function ban_rot() { //First preload images // counter
I have code like this: $(document).ready(function() { $(div #covert, div #coverb).height($(window).height() / 2 +
I have this jquery code: $(document).ready(function() { function slideSwitch() { var $active = $('#slideShow
I have this code and I need an explanation on what it does: function
I have a setInterval running a piece of code 30 times a second. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.