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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:13:34+00:00 2026-06-11T22:13:34+00:00

Simply i have a div which should be animated when i click on a

  • 0

Simply i have a div which should be animated when i click on a button and hidden when i click on another button:

<div id="popup"></div>
<input type="button" value="show and animate popup" onClick="showWithAnimation()" />
<input type="button" value="hide" onClick="aFunction()" />



<script>           
function showWithAnimation(){    

               console.log('animation called');
               $('#popup') .animate({top:(($(window).height()/2)-($('#popup').outerHeight()/2))-70}, 1000, 'easeOutBounce');
           $('#popup').show();
           }

         function aFunction(){//Hide the div

              $('#popup').hide();

          }
</script>

What i noticed, is that the bounce effect is applied on the div only for the first time i click on the show and animate popup, then when i click on hide button and then re-click again on show and animate popup button, the div is shown, but without easeOutBounce effect. may i ask you how to go to solve that? Thanx in advance.

  • 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-11T22:13:35+00:00Added an answer on June 11, 2026 at 10:13 pm

    I think this is happening because when the animation is run, the div is in a certain position on the page…but when you rerun it, the div is already in the target position…so it looks like no animation/effect is happening. It’s happening, it’s just already where you’re trying to animate it to. You need first set the top and left styles to specific values…maybe the top middle of the window. Then, you call animate like you are. This way, whenever you click to show the popup, the popup’s position always starts at the same place, and animates/ends at the same place.

    So you would need:

    $("#popup").css({"top": "whatever", "left": "whatever"}).animate("whatever", "whatever", "whatever").show();
    

    UPDATE:

    When you use animate, it literally animates the selected element(s) from its original values to have the properties you pass it. So in your case, you are animating the top and left styles. By default, the div is positioned somewhere on the page – I think with yours, it’s hidden and just somewhere in the middle of your HTML. So technically, it’s top and left are undefined, but are really some finite values, like “200, 250”. When you call animate, it gradually changes these from the original (200, 250) to what you specify in the animate call. So, after the FIRST animate call, you move (animate) the div to the center of the window. Then you allow the popup to be closed (hidden). Every click to open the popup after that, it attempts to move (animate) the div to the center of the window…but it’s already there (just hidden). So there “isn’t” an animation because it’s trying to move the div to the position it’s already in. Again, as you’ve noticed in your testing, it’s important to note that this happens only after the first time because the div has already been moved to its target position. If you opened the popup, closed it, resized the window, and then opened the popup again, I’m sure there would be some kind of animation (minimally probably). This is because the dynamic target position of the div you specify in the animate call has changed (since the window has resized).

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

Sidebar

Related Questions

suppose I have a simple container which have three element: <div> <span>hello world</span> <input
I have this simple piece of HTML code: <div> <input type=file name=english-file /> </div>
I have a simple jquery animation on a div, which is inside a div,
I have a very simple HTML/JS code, which expands the size of a div
Simply I have a bunch of links like so <div id=categoryLinks> <a href=blah.php?something=this&category=21></a> <a
I have a <div>&nbsp;</div> which has the following styles: background-position: 0 bottom; background-repeat: no-repeat;
I have a menu in which each anchor should do a simple color fade
We have a simple HTML5 video tag and video which, when played, should play
How can i detect external link click? I have a simple question, which may
(PHP 5.3.6) I have a php file which contains simply this text - there

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.