0

I want to hide an image during animation on mouse over. here is my code of animation only

 $('#my_img').animate({'bottom':70}, bouncetime, 'easeOutQuad', function() {
 ....
 });

can you please tell me where and how to put mouse over code so that it hides.

thank you

Praveen
  • 29
  • 4

2 Answers2

0

Not sure how much you know, so to start at the beginning - you will need to put it in a web page (e.g. html) or javascript file.

Inside the web page you will need a script section:

<script type="text/javascript">
</script>

Inside the script you will need to specify the method in jquery (I prefer mouseenter, see here). Something like (updated from your jsfiddle):

$(document).ready(function () {    
    var bouncetime = 1700;
    var ballheight = 280;
    var ballsize = 20;

    $('#my_img').animate({'bottom':20}, bouncetime, 'easeInQuad', function() {
        $('#my_img').animate({'bottom':70}, bouncetime, 'easeOutQuad', function() {             
        });
    });

    $( '#my_img' ).mouseenter( function ()
    {
        $(this).css('visibility','hidden');
    } )

});

Depending on exactly what you want, you could replace the .css(..) with .hide().

You didn't specify it, but to show the image again when the mouse leaves the image, you would do something like (or use hover with two functions rather than mouseenter,mouseleeave see here):

    $( '#my_img' ).mouseleave( function ()
    {
        $(this).css('visibility','visible');
    } )
Community
  • 1
  • 1
acarlon
  • 16,764
  • 7
  • 75
  • 94
0

add this code at the end of all your animation code

$('#my_img').hover(function(){
      $(this).hide();  
    });

here is the demo: http://jsfiddle.net/Ajey/573ht/

Ajey
  • 7,924
  • 12
  • 62
  • 86