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

  • SEARCH
  • Home
  • 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 4256336
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:20:24+00:00 2026-05-21T05:20:24+00:00

Really easy one here, I’m sure – I’m a beginner who’s struggling to integrate

  • 0

Really easy one here, I’m sure – I’m a beginner who’s struggling to integrate setInterval into my jQuery. I currently have this function, which rotates two images upon clicking them. I want this to happen automatically (every few seconds), and can’t seem to find the right way to use setInterval.

Could anyone point me in the right direction? Thanks a lot for any help.

Philip

$(document).ready(function(){
$("#spinitemholder1 .sponsorFlipphil1 img").click(function () {
          $(this).animate({ "width": "0px", "margin-left": "135px" }, 500, function () {
              $(this).parent().hide();
              $(this).width(0);
              $("#spinitemholder1 .sponsorFlipphil2 img").animate({ "width": "271px", "margin-left": "0px" });
              $("#spinitemholder1 .sponsorFlipphil2").show();
          });
      });
      $("#spinitemholder2 .sponsorFlipphil2 img").click(function () {
          $(this).animate({ "width": "0px", "margin-left": "135px" }, 500, function () {
              $(this).parent().hide();
              $(this).width(0);
              $("#spinitemholder1 .sponsorFlipphil1 img").animate({ "width": "271px", "margin-left": "0px" });
              $("#spinitemholder1 .sponsorFlipphil1").show();
          });
      });

});
  • 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-21T05:20:24+00:00Added an answer on May 21, 2026 at 5:20 am

    Try this:

    var interval = setInterval(function () {
      $("#spinitemholder1 .sponsorFlipphil1 img").trigger("click");
      $("#spinitemholder2 .sponsorFlipphil2 img").trigger("click");
    }, 5000);
    

    You have to use “trigger”. I would suggest to reset interval when user clicks one of the images. An easy way would be:

    var interval = 0;
    function startNewInterval() {
      clearInterval(interval); // clear previous one
      interval = setInterval(function () { // start new interval
        $("#spinitemholder1 .sponsorFlipphil1 img").trigger("click");
        $("#spinitemholder2 .sponsorFlipphil2 img").trigger("click");
      }, 5000);
    }
    
    $("#spinitemholder1 .sponsorFlipphil1 img").click(function () {
      $(this).animate({ "width": "0px", "margin-left": "135px" }, 500, function () {
        $(this).parent().hide();
        $(this).width(0);
        $("#spinitemholder1 .sponsorFlipphil2 img").animate({ "width": "271px", "margin-left": "0px" });
        $("#spinitemholder1 .sponsorFlipphil2").show();
        startNewInterval();
      });
    });
    
    $("#spinitemholder2 .sponsorFlipphil2 img").click(function () {
      $(this).animate({ "width": "0px", "margin-left": "135px" }, 500, function () {
        $(this).parent().hide();
        $(this).width(0);
        $("#spinitemholder1 .sponsorFlipphil1 img").animate({ "width": "271px", "margin-left": "0px" });
        $("#spinitemholder1 .sponsorFlipphil1").show();
        startNewInterval();
      });
    });
    
    startNewInterval();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I feel like this question has a really easy answer and I'm just overlooking
I'm trying to do something that used to be really easy before the start
Should be a really quick one for you pro's: I'm learning to use JS,
I am getting a bit frustrated with prism. Something that should be so easy
I really like using the sample data binding at design time for Silverlight. It
My goal is to simply use a pop-up box to ask the user for
I'm having a serious problem with a prestashop shipping module for FedEx. I know
I have been looking for an elegant way to write a function that takes
I'm neither good nor experienced about asking questions so i hope I'm not doing
I've stumbled upon this issue and my noob brain got fried trying to resolve

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.