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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:37:59+00:00 2026-06-14T03:37:59+00:00

//this code animates the divs to the left after every 5 secs $(document).ready(function() {

  • 0
//this code animates the divs to the left after every 5 secs
$(document).ready(function() {

    var refreshId = setInterval(function() {
        $('.box').each(function() {
            if ($(this).offset().left < 0) {
                $(this).css("left", "150%");
            } else if ($(this).offset().left > $('#container').width()) {
                $(this).animate({
                    left: '50%'
                }, 500);
            } else {
                $(this).animate({
                    left: '-150%'
                }, 500);
            }
        });
    }, 5000);)
};​

In the above code, whenever the page gets loaded the div elements keep sliding every 5 secs. But there is a button in my webpage which, when clicked, moves the div elements to the left or right respectively according to the button clicked. But the problem is the auto animation and animation occuring on buuton click sometimes overlap. So whenever I click the button I want to delay the auto animation in document.ready by 5 secs again.

This is shown in this jsFiddle. When you keep clicking on the “left animation” or “right animation” buttons, the divs overlap sometimes. So I just want to delay the auto animation whenever I click the buttons.

  • 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-14T03:38:00+00:00Added an answer on June 14, 2026 at 3:38 am

    You can call clearInterval(refreshId), and then re-run your code to set up the rotation.

    Here’s a rough sketch of how you could do it. I’m afraid I probably can’t provide more detail than this, but I hope it helps!

    $(document).ready(function () {
        var refreshId;
        function startRotation() {
            refreshId = setInterval(function () { /* rotate stuff */ }, 5000);
        }
        function restartRotation() {
            clearInterval(refreshId);
            startRotation();
        }
        startRotation();
    
        var button = /* find the buttons that should restart the rotation */;
        button.click(restartRotation);
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I mean I have this code: <script> $(document).ready( function() { $('html, body').animate({ scrollTop: $(.error).offset().top
I have pretty simple jquery code : $(document).ready(function(){ $('img.marqFl').on({ mouseenter: function() { $(this).animate({height: 300},
I m un-animating a list using this code... function unanimate_li() { $li.filter(':last') .animate({ height:
The code like this: $(.hide).click(function(){ $(.online-contact).animate({width: 'toggle',height: '100%'}, fast); $(this).hide(); $(.show-class).show(); }) I want
here is my old code which works: $('.logo').hover(function(){ $(this).addClass('animated swing')}, function(){$(this).removeClass('animated swing') }); here
$('#div1, #div2').click(function(){ //Code to execute onclick }); $('#div1, #div2').hover(function(){ $(this).animate({ 'filter':'alpha(opacity=100)', '-moz-opacity':'1', '-khtml-opacity':'1', 'opacity':
How would I modify this code to show the animated movement (item moving from
... SecondViewController *svc = [SecondViewController new]; [self presentViewController:svc animated:YES completion:NULL]; } This code is
$(#maincontent).animate({top:450px},1200) .html($(#+Lidentity).html()) .animate({top:0px},1000); Hi friends, This is jquery code, which is working fine. As
This code below allows me to find the word error in all my files

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.