Animating Resizing an Image

$("img").mouseover(function(){     $(this).animate(       {width:"200px", opacity:1}, 1000); }); $("img").mouseout(function(){     $(this).animate(       {width:"100px", opacity:.3}, 1000); });

Similar to the way you use the height and width to create a sliding effect, you can use them to create a resize animation. The difference between a slide and a resize is that the aspect ratio of the image is maintained on a resize, so the element appears to be growing or shrinking rather than being unfolded or untucked.

To create a resize animation, you need to specify both height and width in the .animate() statement, or one of them has to be auto in the CSS settings and you can only animate ...

Get jQuery and JavaScript Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.