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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:15:11+00:00 2026-06-09T14:15:11+00:00

I am trying to animate a div up and down, in quick succession, for

  • 0

I am trying to animate a div up and down, in quick succession, for a limited time. This works in jquery to make it happen, but it is so messy:

 $('.wiggle').delay(1800).show(50).animate({
                top: '15'
                              }, 40, function() {
                                 $('.wiggle').animate({
                                 top: '12'
                                 }, 40, function() {
                                    $('.wiggle').animate({
                                    top: '15'
                                    }, 40, function() {
                                        $('.wiggle').animate({
                                        top: '12'
                                        }, 40, function() {
                                            $('.wiggle').animate({
                                            top: '15'
                                            }, 40, function() {
                                                $('.wiggle').animate({
                                                top: '12'
                                                }, 40, function() {
                                                    $('.wiggle').animate({
                                                    top: '15'
                                                    }, 40, function() {
                                                        $('.wiggle').animate({
                                                        top: '12'
                                                        }, 40, function() {
                                                            $('.wiggle').animate({
                                                            top: '15'
                                                            }, 40, function() {
                                                                $('.wiggle').animate({
                                                                top: '12'
                                                                }, 40, function() {
                                                                    $('.wiggle').animate({
                                                                    top: '14'
                                                                    }, 40, function() {
                                                                        $('.wiggle').hide(50)
                                                                     });
                                                                 });
                                                             });
                                                         });
                                                     });
                                                 });
                                             });
                                         });
                                     });
                                 });
                             }); //end wiggle

I know it is bad. I’d like to create a unique function to make this happen, but I am lost as to where to start.

  • 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-09T14:15:13+00:00Added an answer on June 9, 2026 at 2:15 pm

    I suggest you decide how long overall you want the effect to run, then encapsulate the actions into a single function that will take care of recursing and stopping:

    function wiggle(selector, duration_of_wiggle) {
        var wiggle_active = true;
        var target = $(selector);
        setTimeout(function () {
            wiggle_active = false;
            target.hide();
        }, duration_of_wiggle);
        var one_wiggle_down = function () {
            if (!wiggle_active)
                return;
            target.animate({
                top: '15'
            }, 40, one_wiggle_up);
        };    
        var one_wiggle_up = function () {
            if (!wiggle_active)
                return;
            target.animate({
                top: '12'
            }, 40, one_wiggle_down);
        };
        one_wiggle_down();
    };
    
    wiggle('.wiggle', 1000);
    

    Try it here: http://jsfiddle.net/P4H9c/1/

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

Sidebar

Related Questions

I'm trying (with very limited jQuery knowledge :) to animate a DIV when you
I am trying to make a div move left and right but my animate
I'm trying to animate the opacity of a div using jQuery. It works fine
I am trying to find a way to animate a div using jQuery to
I'm trying to animate a logo. The markup looks like this: <div id=logo> <h1>
I've been trying to animate a Dashboard Widget's div disappearance, but it just brutally
I'm using the latest version of JQuery and trying to animate a div to
I'm trying to animate and image up and then down with jQuery. It should
I'm trying to animate a div's width after the page loads, but I cannot
I'm trying to animate the div within an list item with a click event

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.