This page was created by a UCSB student!
This page covers various uses of the jQuery animate method, which allows users to create custom animations.
$(selector).animate({params}, speed, callback)
Let's start with a simple animation example, then we'll look into more intricate uses of jQuery animate().
The following jQuery code will move the square HTML div to the right, increases the width of the div, increase the size of the text in the div, and change the opaqueness of the div's background color.
A few things to note from this example...
Now, what if we want to animate something multiple times in a row, each time with different animations?
If you write multiple calls to animate(), each call will be executed one after another.
In this code screenshot, jQuery creates a queue of the successive calls to animate() and processes them one after another.
Try this example problem:
Animate the HTML div such that when the button is clicked, the div will slowly move in a digital figure 8 motion (shown below) and the opacity of the background color will change.
Note: The CSS and jQuery code for this page is in the head section rather than spearate files. This is NOT good to do in a fully developed web site. However, it makes writing the code more convenient for this exercise.
More about jQuery animate:
W3 Schools - jQuery Animate