[jQuery] get hover function behave right
Hi,
I want to animate the width and height of image when hovering it, and
when i stop the image's state back to normal.
My problem is, the image's state not back to normal when mouseout.
here is my code
$(function(){
$('img').hover(function(){
var curwidth = $(this).width(), curheight = $(this).height();
var aimwidth = curwidth +20, aimheight = curheight +20;
$(this).stop().animate({width:aimwidth, height:aimheight},400);
}, function(){
$(this).stop().animate({width:curwidth, height:curheight},400);
});
});
And HTML
<img src="img/1oaxwk.jpg" width="40" height="40" />