The jQuery animate() method provides you a way to create custom animations.
Syntax:
$(selector).animate({params}, speed, callback);
Here, params parameter defines the CSS properties to be animated.
The speed parameter is optional and specifies the duration of the effect. It can be set as "slow" , "fast" or milliseconds.
The callback parameter is also optional and it is a function which is executed after the animation completes.
Let's take a simple example to see the animation effect.
A simple animation example:
Output:
A simple animation example:
You can use multiple properties to animate at the same time.
Output:
You can also define relative values (it is relative to the element's current value) by putting += or -= in front of the value.
Output:
You can also specify a property's animation value as "show" , "hide" , or "toggle".
In this example, we are using "toggle" value for height, it means it will show/hide the selected element.
Output:
You can also animate the properties of elements between colors.
jQuery UI Effects - Animate demo Animate
rookienerd.com is the best tutorial website to learn Java and other programming languages.