jQuery Animate

1. Introduction

With jQuery animate, we can create custom animations, in addition to the jQuery basic effects that we had learnt earlier.

2. Syntax

where params can be CSS properties to be altered with animation, speed can be ‘slow’, ‘fast’ or the time in milliseconds, and lastly the callback parameter is optional, which is the function or set of statements that needs to be executed after the animation completes.

Almost all the CSS properties can be animated with jQuery animate function, however the CSS properties as jQuery animate parameter needs to be specified in camel-case instead of an intermediate hyphen, as we do while writing a standard CSS. For example, margin-top property needs to be specified as marginTop with jQuery animate.

3. Example Code


Receive our updates to your inbox

Get more stuff like this
in your inbox

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.