Virtual Classes Logo          Virtual Classes
    Read Anytime,Anywhere

JQuery Animation

The jQuery has provided animate() method which helps developer to create custom animations.
The required params parameter defines the CSS properties to be animated.
The optional speed parameter specifies the duration of the effect.It can take the following values: "slow", "fast", or milliseconds.
The optional callback parameter is a function to be executed after the animation completes.

Example: $("div").animate({left: '250px'});

Below example shows to manipulate multiple css properties
Example: $("div").animate({
             left: '250px',height: '150px',width: '150px'

JQuery stop() Method:Stop() method is used to stop an animation or effect before it is finished.
The stop() method works for all jQuery effect functions, including sliding, fading and custom animations.
The optional stopAll parameter specifies whether also the animation queue should be cleared or not.Default is false, which means that only the active animation will be stopped, allowing any queued animations to be performed afterwards.

The optional goToEnd parameter specifies whether or not to complete the current animation immediately. Default is false.So, by default, the stop() method kills the current animation being performed on the selected element.
The following example demonstrates the stop() method, with no parameters:
Above code will stop running animation on div when user will click on stop button.