Reddy
Reddy

Reputation: 1385

On image mouseover zoom

Here is my jQuery code..

 $('img').live('mouseenter',function()
          {  
              $(this).addClass('shown');
              $('.shown').animate({width: '+=50',height: '+=50'})
          });

 $('img').live('mouseleave',function()
          {
              $(this).removeClass('shown');
              $(this).addClass('reset');
               $('.reset').animate({width: '-=50',height: '-=50'})
          });

It is removing the image after some mouse enters.. Please help me..

Upvotes: 0

Views: 1043

Answers (1)

Clayton
Clayton

Reputation: 5350

You are making selection of the image to animate more complicated than it needs to be:

$('img').hover(
    function () { 
        $(this).animate({width: '+=50', height: '+=50'});
    },
    function () {
        $(this).animate({width: '-=50', height: '-=50'});
    });

Upvotes: 2

Related Questions