Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need to animate an object to top and make it go back

I need my plane to fly up the runway (which is the map) and come back on click. So far it only goes up. Anything java script/html/ jquery related. simple suggestions please. ty ^^ Here's my current code::

<div class="Map"><div id="MovingPlane1"></div></div>

JS :

<script type="text/javascript">
    $(document).ready(function(){
        $("#MovingPlane1").click(function(){
            $("#MovingPlane1").animate({bottom:"250px"},"slow");
        });
    });
<script>
like image 686
needhelp Avatar asked Dec 04 '25 06:12

needhelp


1 Answers

jsBin demo

Give both your planes a class .plane and use this code:

$(".plane").click(function(){
      
   $(this).animate({bottom:250},800,function(){
       $(this).animate({bottom:0},800);
   });
  
});

Inside the animation callback you redo the initial position.

like image 160
Roko C. Buljan Avatar answered Dec 05 '25 22:12

Roko C. Buljan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!