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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:58:23+00:00 2026-06-14T15:58:23+00:00

I was trying to repeat the entire function in a loop but nothing works.

  • 0

I was trying to repeat the entire function in a loop but nothing works. I tried Loop () callback, set interval(). Can someone point me to the right direction?

What would be the best method to repeat the entire animation? Thanks

$(document).ready(function() {
    $("#slide1").fadeIn(500, function() {
        $("#slide2").fadeIn(500, function() {
            $("#slide3").fadeIn(500, function() {
                $("#slide4").fadeIn(500, function() {
                    $("#slide5").fadeIn(500, function() {

                        $("#slide1").fadeOut(500, function() {

                            $("#slide6").fadeIn(500, function() {
                                $("#slide7").fadeIn(500, function() {
                                    $("#slide8").fadeIn(500, function() {
                                        $("#slide9").fadeIn(500, function() {});
                                    });
                                });
                            });
                        });
                    });
                });
            });
        });
    });
});
  • 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-14T15:58:24+00:00Added an answer on June 14, 2026 at 3:58 pm

    @Phillip So what ever you have in the question works now.. you just want the code to be improvised.. Is that correct? – Vega

    Hi Vega. Yes the code works nicely but would like the $("#slide1").fadeOut(500, function() { to occur. thanks – Phillip

    Converted the code you have like below,

    DEMO: http://jsfiddle.net/RuX5d/5/

    $(document).ready(function() {
        var i = 1, dir = 1, curFx = 'fadeIn';
        var interval = setInterval(function () {
            if (i == 6 && $('#slide1').is(':visible')) {
                $('#slide1').fadeOut(500);             
                return;
            }
    
            $('#slide'+ i)[curFx](500);
    
            i = i + 1*dir;
    
            if (i == 10 || i == -1) {
                dir = (dir == 1)?-1:1;
                curFx = (curFx == 'fadeIn')?'fadeOut':'fadeIn';
            }        
        }, 500);
    });
    

    I am not very sure about what you want.. but I believe you want to fadeIn and fadeOut content repeatedly.

    If so, try my demo and code below,

    DEMO: http://jsfiddle.net/RuX5d/1/

    $(document).ready(function() {
        var curSlide = 0, dir = 1;
        var curFx = 'fadeIn';
        setInterval(function () {
            curSlide += 1 * dir;
            $('#slide' + curSlide)[curFx](500);
            if (curSlide == 11 || curSlide == 0) {
                curFx = (curFx == 'fadeIn')?'fadeOut': 'fadeIn';
                dir = (dir == 1)?-1: 1;
            }
        }, 500);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to set the background of an element to no-repeat - I've tried
I'm trying to get a function to repeat itself once it starts, but I
I am trying to repeat something inside a jquery function. I tried a for
I am trying to set a background to a canvas, and set an repeat-x
(look also at my previous question ) I'm trying to repeat set of curlopt
I'm trying to update an element within an UI-repeat, but unfortunately I still haven't
I'm trying to create a function in Factor Code called repeat which expects a
I am trying to repeat a code execution after predefined time passes and i
I'm trying to not repeat code, so I have a method that does a
I've switched over to kineticJS and I'm trying to have a background image repeat

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.