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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:40:53+00:00 2026-06-18T01:40:53+00:00

If I have a function like so: function x() { animate(a, 2000); animate(b, 3000);

  • 0

If I have a function like so:

function x()
{
    animate(a, 2000);
    animate(b, 3000);
    animate(c, 4000);
}

Where – a, b & c – are variables representing elements on the page, and the number is a parameter passed to an animate() function that uses it as a duration value for a timeout, like so:

function animate(src, dur)
{
    setTimeout(function() {
        src.style.opacity = 1;
    }, dur);
}

Everything so far is fine, but if I want the ability to break out of the animation loop, how do I go about it? Will clearTimeout() be what I’m looking for?

  • 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-18T01:40:54+00:00Added an answer on June 18, 2026 at 1:40 am

    Variables that have been assigned a timeout, may be passed to the clearTimeout function, which will cease the function. You can store these variables in an array and easily clear all timeouts by iterating this array and passing the timeout to the clearTimeout function.

    var timeouts = [];
    
    /* Save timeouts into a variable and push to an array */
    function animate(src, dur)
    {
        var timeout = setTimeout(function() {
            src.style.opacity = 1;
        }, dur);
        timeouts.push(timeout);
    }
    
    /** Clear all timeouts**/
    function clearTimeouts(){
       for(var i = 0; i < timeouts.length; i++){
         clearTimeout(timeouts[i]);
       }
    }
    
    //Create timeouts
    x();
    //Invoke clearTimeouts
    clearTimeouts();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Everything works fine except the animate click function. I would like to have the
Let's say I have something like function animate(param) { // ... if (param <
I have a jQuery function like so: $(this).animate({ width:100+'px' }, 300); How can I
function character_1() { $(#character_1).animate({top: 0}, 3000, function() { $(this).fadeOut(2000); character_2(); }); }; function character_2()
Explanation I have a function that is passed the parameter options . This parameter
I have function like this: function ypg_delete_img($id, $img) { $q = $this->ypg_get_one($id); $imgs =
I have function like this: function gi_insert() { if(!IS_AJAX){ $this->load->library('form_validation'); $this->form_validation->set_rules('name', 'Naslov', 'trim|required|strip_tags'); $this->form_validation->set_rules('body',
let say i have function like below function doSomethingNow(){ callSomethingInFutureNotExistNow(); } at the moment
I am trying to learn JavaScript... I have function like, I take the format
I have a function like the following: // Convert To JPG // public string

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.