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 8845809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:49:21+00:00 2026-06-14T11:49:21+00:00

I have 2 jquery animations. I want them both to loop infinitely. There needs

  • 0

I have 2 jquery animations. I want them both to loop infinitely. There needs to be a delay on the second animation of 3 seconds but only the first time it triggers. Once the second animation has started, there needs to be no delay.

I’ve created a striped down version of the code so far to make it clearer.

The HTML:

<div class="block1"></div>
<div class="block2"></div>

The CSS:

div.block1,
div.block2 { 
  position: absolute;
  display: block;
  top: -100%;
  height: 100%;
  width: 100%; }

The jQuery

function block1(){
  $("#block1").animate({ top: '100%'}, 6000, 'linear', function(){ $(this).css('top', '-100%') });
  block1();
}

function block2(){
  $("#block2").animate({ top: '100%'}, 6000, 'linear', function(){ $(this).css('top', '-100%') });
  block2();
}

block1();
block2();

So I have 2 problems with this. Firstly when I try to call the second function (block2), it doesn’t work. Secondly, I’m not sure how to apply the delay I’m after. Any suggestions?

  • 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-06-14T11:49:22+00:00Added an answer on June 14, 2026 at 11:49 am

    You can use this code to set delay initially then animation will work infinitely without any delay. setTimeout will call block1 function with specified delay, once 1st animation completes then it’ll make call to 2nd and this will continue for indefinite.

    JS:

    function block1() {
        $(".block1").animate({
            top: '+=10px'
        }, 600, 'linear', function() {
            block2();
        });
    }
    
    function block2() {
        $(".block2").animate({
            top: '+=10px'
        }, 600, 'linear', function() {
            block1();
        });
    }
    
    setTimeout(block1, 3000);​
    

    CSS:

    div.block1, div.block2 { 
      position: absolute;
      display: block;
      top: 0;
      height: 100px;
        width: 100px; 
       background-color: red; 
    }
    
    div.block2 { top: 200px; } 
    

    HTML:

    <div class="block1">Block 1</div>
    <div class="block2">Block 2</div>​
    

    WORKING DEMO

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a jQuery line that execute 2 animations, what i want is to
I have two jquery animations running in two different elements. Both are triggered at
I have a problem with animations using jQuery on nested tables. I want to
I have several jquery animations running, each of which will need to be somewhat
I have a simple jquery animation on a div, which is inside a div,
I have created a jQuery animation that can be seen by clicking the Preview
I have a simple jquery flipcard animation - http://jsfiddle.net/gGAW5/36/ Now the way this flip
Doing some jquery animation. I have certain divs set up with an attribute of
I am having jQuery animation issues... I have a footer with a hidden div
I have used JQuery for a small animation work: a table #photos contains 9

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.