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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:58:24+00:00 2026-05-14T04:58:24+00:00

Under $(document).ready(function() , I have the following code: num = $(#mainContentCategoryLinksWrapper > div).size(); This

  • 0

Under $(document).ready(function(), I have the following code:

num = $("#mainContentCategoryLinksWrapper > div").size();

This makes num equal the length of the children of #mainContentCategoryLinksWrapper. Currently, this equals 4. Above the $(document).ready(function( I have this:

var timesRun = 0;

    function slideshow(){


        if(timesRun < num){
                     $(".arrowIn").stop().animate({color: "#a12324", textIndent: "30px", backgroundPosition: '0px 0px'}, 100, function(){ //the first child in the series has a class of "arrowIn"

                                                                        $(".arrowIn").next().addClass("replaceMe"); //Adds the ".replaceMe" placeholder the the next element.
                                                                          $(".arrowIn").removeClass("arrowIn"); //Deletes the class on the current element
                                                                          $(".replaceMe").addClass("arrowIn").removeClass("replaceMe"); //reassigns ".arrowIn" over ".replaceMe"    
                                                                          timesRun = timesRun + 1; //increases number of times run

                                                                                                                                        }).prev().animate({color: "#000000", textIndent: "25px", backgroundPosition: '0px -25px'}, {duration: 50}); //puts the previous element back to it's original position

                        }else{

                            timesRun = 0;
                            $(".arrowIn").removeClass("arrowIn");
                            $("#mainContentCategoryLinksWrapper:first-child").addClass("arrowIn"); //this is supposed to reset timesRun, and set the first child in the series back to the original ".arrowIn" 
                }




    }

setInterval( 'slideshow()', 1000 );

So here is the what the code does:

1) Animates the first in the series of 4 (#1) timesRun = 1
2) Animates the second in the series of 4 (#2) timesRun = 2
3) Animates the third in the series of 4 (#3) timesRun = 3
4) Animates the fourth in the series of 4 (#4) timesRun = 4
5) timesRun is now longer less than num. Reset class names back to original to .arrowIn, set timesRun to 0.

However, when the slideshow() is reexectuted, it doesn’t start over.

Any ideas? See http://www.raceramps.com/v3 for an example.

  • 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-14T04:58:24+00:00Added an answer on May 14, 2026 at 4:58 am

    it seems to me that you declared the function inside $(document).ready() block.
    if that so it will sure will not work because the function life cycle is limited to the “ready” block and when it finishes the declarations will not be visible to any other elements outside the “ready” block
    so what you should do is declare the function outside the “ready” as follow

    function slideshow(){
    // your stuff
    }
    $(document).ready(
    function () {setInterval( 'slideshow()', 1000 );
    }
    )
    

    Update:
    try to make the reset line selector same as the get size selector, like this

    $("#mainContentCategoryLinksWrapper>div:first-child").addClass("arrowIn");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 436k
  • Answers 436k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This should get close to what you describe: $(function ()… May 15, 2026 at 3:47 pm
  • Editorial Team
    Editorial Team added an answer You "know" that function objects incur overhead? Perhaps you should… May 15, 2026 at 3:47 pm
  • Editorial Team
    Editorial Team added an answer The file that is attached with the project is bundled… May 15, 2026 at 3:47 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.