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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:11:10+00:00 2026-06-04T22:11:10+00:00

function character_1() { $(#character_1).animate({top: 0}, 3000, function() { $(this).fadeOut(2000); character_2(); }); }; function character_2()

  • 0
function character_1() {
    $("#character_1").animate({"top": "0"}, 3000, function() {
        $(this).fadeOut(2000);
        character_2();
    });
};

function character_2() {
    $("#character_2").animate({"top": "0"},3000, function() {
        $(this).fadeOut(2000);
        character_3();
    });
};

function character_3() {
    $("#character_3").animate({"top": "0"},3000, function() {
        $(this).fadeOut(2000);
        character_1();
    });
};

$(document).ready(function() {
    character_1();
});

The code above. It doesn’t return to character_1(); I’d like to have them running as loop. Anyone help please?

  • 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-04T22:11:12+00:00Added an answer on June 4, 2026 at 10:11 pm

    As I mentioned in comments: Your looping is fine, but all elements are faded out after executing character_3() and so you don’t see the return back to character_1(). You need to reset the animation to original state before you could call character_1(). Check below for an sample of how to set it back to original state.

    Also the sequencing was little off because of the fadeOut animation, so I moved to call to next animation inside fadeOut callback so that it is properly sequenced.

    Edit: I have done some optimization and used timer instead of endless loop. Check below,

    Can handle any number of boxes with no change to the code

    $(function() {
        var $chars = $('.chars');
        var curIndex = 0, charTop = 0;
    
        function animateChars() {
            setTimeout(function() {
                if (curIndex >= $chars.length) {
                    curIndex = 0;
                    if (charTop == 200) {
                        charTop = 0;
                    } else {
                        charTop = 200;                    
                    }
                    $.when($chars.fadeIn(2000)).then(animateChars());
                } else {
                    console.log(curIndex);
                    $chars.eq(curIndex).animate({
                        "top": charTop
                    }, 3000, function() {
                        $(this).fadeOut(2000, function() {
                            curIndex++;
                            animateChars();
                        });
                    });
                }
    
            }, 100);
        }
        animateChars();
    });
    

    DEMO

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

Sidebar

Related Questions

I have the following code: $(li.item).live('click',function() { $('#menu').animate({ }, 500); }); Now, I would
My code works and I animate, but I'm not sure how to do this:
This function gives me the following error: SyntaxError: Invalid character '\u8203' All looks good
This function in pkg go/token makes me wonder why we need a method that
I have this script: function slideSwitch() { var ae = jQuery('#featured-right a.active'); if (
I want to be able to do this $('.class').bind({'click':'function(){ ... }'}); // note that
Is there any equivalent function that returns the character at position X in PHP?
Is there an existing function to replace accented characters with unadorned characters in PostgreSQL?
The max number of characters you can use in string in a vba function
I need a function that returns the ASCII value of a character, including spaces,

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.