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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:53:20+00:00 2026-06-15T02:53:20+00:00

I have items being added and removed (append & prepend) and would like this

  • 0

I have items being added and removed (append & prepend) and would like this to pause on both hover and on a click.

Please see my custom function I have built below. I would like to be able to pause this sequence by clicking a button with a certain class and resume it with the same button (play/pause type of thing. Ideally it would also pause onhover of the div to which the items are being added/removed.

It would be great to get a solution for this particular scenario but also if possible a more general one regarding pausing/resuming custom functions as I understand .stop does not work unless the function is an offical jquery one

Any help/Guidance is much appreciated, I am fairly new to this so the more thorough (idiot’s guide) an explanation the better

Thanks!

$(function() {


   var SECONDS_BETWEEN = 5;
        var SLIDE_DURATION  = 1;
        var FADE_DURATION   = 1;

        var items = [];

         $(document).ready(function() {
            $('.item').each(function() {items.push($(this)); $(this).remove()});
            add_item();
        });

        function add_item() {
            var item = items.shift();


             item.removeAttr('style');
            item.find('.contentitem').removeAttr('style');   

            item.hide().prependTo('.innerwrapper')
                .slideDown(
                    SLIDE_DURATION*1000, 
                    function() {           
                        item.find('.contentitem').fadeTo('slow', 1);
                    }
                );


            items.push(item);


            setTimeout(add_item, SECONDS_BETWEEN*1000)


        }


});
  • 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-15T02:53:21+00:00Added an answer on June 15, 2026 at 2:53 am

    An easy way to do it is to store a flag that can be accessed by another function, such as the callback from a click on a button.
    At the beginning of your add_item() function, you should check that that flag is properly set, allowing you to go on.

    In your example:

    $(function() {
        var SECONDS_BETWEEN = 5;
        var SLIDE_DURATION  = 1;
        var FADE_DURATION   = 1;
    
        /* Define a flag to pause the animation */
        var paused = false;
        var items = [];
    
         $(document).ready(function() {
            $('.item').each(function() {items.push($(this)); $(this).remove()});
            add_item();
         });
    
    
         $(".togglebutton").click(function() {
             /* Toggle the animation */
             paused = !paused;
         });
    
        function add_item() {
            /* Check the flag */
            if(!paused) {
                var item = items.shift();
                item.removeAttr('style');
                item.find('.contentitem').removeAttr('style');   
    
                item.hide().prependTo('.innerwrapper')
                    .slideDown(
                        SLIDE_DURATION*1000, 
                        function() {           
                            item.find('.contentitem').fadeIn('slow');
                        }
                    );
    
                items.push(item);
            }
            setTimeout(add_item, SECONDS_BETWEEN*1000);
        }
    });​​​
    

    You can check this Here.

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

Sidebar

Related Questions

So I have a TreeView like the one below, with certain items being hidden.
WPF controls have certain properties (UserControl.Resources, UserControl.CommandBindings) that can have items added to them
In my model I have an array of objects called events. I would like
I have items in a list in a SharePoint 2003 site that I need
I have an element that have items and a tag. The element can contain
If i have items stored in a database that users can download after they
I have a database with Users. Users have Items. These Items can change actively.
I'm trying to use iexact in my Django app. I have items in my
I have some items in my .emacs that I don't want to run if
I have some items called tickers which can be created and subscribed to. When

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.