Understanding jQuery’s .animate() API

Written by Fikri Rasyid

jQuery Image

There are lots of handy jQuery APIs, but in my opinion, one of the jQuery fanciest API is .animate(). We can simply say that animate is about transitioning any CSS property you want. Let’s say you have this 100 X 100 pixels box and you want to change its size to 150 X 150 pixels once user clicks it. This is the ‘plain way’ of doing it:

While it gets the stuff done, compare the way its size is changing by using .animate():

Prettier, isn’t it? That’s what .animate does: it changes css properties (dimension, color, opacity, display, background color, you name it). However, rather than ‘jumping’ the values of the properties, it changes the CSS properties you stated by transitioning it from the current values to desired values, one step at time, which makes it looks animated. Hey, the name of the API is animate(), right? :D

About The Author

Fikri Rasyid - I speak HTML + CSS + jQuery, breath in world wide WordPress-land, co-founded WPNest and currently pursuing my bachelor degree majoring English Education at Indonesia University of Education. Google my name for more information about me.

Connect & Subscribe

Keep in touch and get my latest content trough:

Categories

Post Info

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>