O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Animating CSS Settings

$("img").animate({height:100, width:100}); $("p").animate({margin-left:30});

Most animation in jQuery is done via the .animate() method. The .animate() jQuery method allows you to implement animations on one or more CSS properties. Keep in mind that the .animate() method acts on all elements in the jQuery object set at the same time. Often, you only want to act on a single element, so you need to filter the set down to one.

The .animate() method accepts a CSS property object mapping as the first argument. You can specify more than one property in the object to animate multiple properties at the same time. For example, the following code animates the height and width properties for <img> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required