The following table lists all the jQuery methods for creating animation effects.
Method | Description |
---|---|
animate() | Runs a custom animation on the selected elements |
clearQueue() | Removes all remaining queued functions from the selected elements |
delay() | Sets a delay for all queued functions on the selected elements |
dequeue() | Removes the next function from the queue, and then executes the function |
fadeIn() | Fades in the selected elements |
fadeOut() | Fades out the selected elements |
fadeTo() | Fades in/out the selected elements to a given opacity |
fadeToggle() | Toggles between the fadeIn() and fadeOut() methods |
finish() | Stops, removes and completes all queued animations for the selected elements |
hide() | Hides the selected elements |
queue() | Shows the queued functions on the selected elements |
show() | Shows the selected elements |
slideDown() | Slides-down (shows) the selected elements |
slideToggle() | Toggles between the slideUp() and slideDown() methods |
slideUp() | Slides-up (hides) the selected elements |
stop() | Stops the currently running animation for the selected elements |
toggle() | Toggles between the hide() and show() methods |
The animate() method performs a custom animation of a set of CSS properties
This method changes an element from one state to another with CSS styles. The CSS property value is changed gradually, to create an animated effect.
Only numeric values can be animated (like "margin:30px"). String values cannot be animated (like "background-color:red"), except for the strings "show", "hide" and "toggle". These values allow hiding and showing the animated element.
(selector).animate({styles}, speed, easing, callback)
Parameter | Description |
---|---|
styles | Required. Specifies one or more CSS properties/values to animate. Note: The property names must be camel-cased when used with the animate() method: You will need to write paddingLeft instead of padding-left, marginRight instead of margin-right, and so on. Properties that can be animated: Click to try yourself- Below link.....
Only numeric values can be animated (like "margin:30px"). String values cannot be animated (like "background-color:red"), except for the strings "show", "hide" and "toggle". These values allow hiding and showing the animated element. |
speed | Optional. Specifies the speed of the animation. Default value is 400 milliseconds Possible values:
|
easing | Optional. Specifies/define the speed of the element in different points of the animation. Default value is "swing". Possible values:
|
callback | Optional. A function to be executed after the animation completes. To learn more about callback, please read our jQuery Callback chapter |
(selector).animate({styles},{options})
Parameter | Description |
---|---|
styles | Required. Specifies one or more CSS properties/values to animate (See possible values above) |
options | Optional. define additional options for the animation. Possible values:
|
"Animate" an element, by changing its height
The clearQueue() method removes all items from the queue that have not yet been run. Note that when a function has started to run, it runs until it is completed.
Related methods
$(selector).clearQueue(queueName)
Parameter | Description |
---|---|
queueName | Optional. Specifies the name of the queue The default is "fx", the standard effects queue |
The delay() method sets a timer to delay the execution of the next item in the queue.
$(selector).delay(speed,queueName)
Parameter | Description |
---|---|
speed | Optional. Specifies the speed of the delay Possible values:
|
queueName | Optional. Specifies the name of the queue Default is "fx", the standard effects queue |
The dequeue() method removes the next function from the queue, and then executes the function.
A queue is one or more function(s) waiting to run.
The dequeue() method is used together with the queue() method.
An element can have several queues. Most often it has only one, the "fx" queue, which is the default jQuery queue.
Note: You should ensure that the dequeue() method is called after adding a function with queue(), to allow the process to continue.
$(selector).dequeue(queueName)
Parameter | Description |
---|---|
queueName | Optional. Specifies the name of the queue Default is "fx", the standard effects queue |
The fadeIn() method gradually changes the opacity, for selected elements, from hidden to visible (fading effect).
$(selector).fadeIn(speed,easing,callback)
Parameter | Description |
---|---|
speed | Optional. Specifies the speed of the fading effect. Default value is 400 milliseconds Possible values:
|
easing | Optional. Specifies the speed of the element in different points of the animation. Default value is "swing" Possible values:
|
callback | Optional. A function to be executed after the fadeIn() method is completed
To learn more about callback, visit our jQuery Callback chapter |
Fade in all <p> elements:
The fadeOut() method gradually changes the opacity, for selected elements, from visible to hidden (fading effect).
Note: Hidden elements will not be displayed at all (no longer affects the layout of the page).
$(selector).fadeOut(speed,easing,callback)
Parameter | Description |
---|---|
speed | Optional. Specifies the speed of the fading effect. Default value is 400 milliseconds Possible values:
|
easing | Optional. Specifies the speed of the element in different points of the animation. Default value is "swing" Possible values:
|
callback | Optional. A function to be executed after the fadeOut() method is completed
To learn more about callback, visit our jQuery Callback chapter |
Fade out all <p> elements
The fadeTo() method gradually changes the opacity, for selected elements, to a specified opacity (fading effect).
$(selector).fadeTo(speed,opacity,easing,callback)
Parameter | Description |
---|---|
speed | Required. Specifies the speed of the fading effect. Possible values:
|
opacity | Required. Specifies the opacity to fade to. Must be a number between 0.00 and 1.00 |
easing | Optional. Specifies the speed of the element in different points of the animation. Default value is "swing" Possible values:
|
callback | Optional. A function to be executed after the fadeTo() method is completed
To learn more about callback, visit our jQuery Callback chapter |
The fadeToggle() method toggles between the fadeIn() and fadeOut() methods.
If the elements are faded out, fadeToggle() will fade them in.
If the elements are faded in, fadeToggle() will fade them out.
number
$(selector).fadeToggle(speed,easing,callback)
Parameter | Description |
---|---|
speed | Optional. Specifies the speed of the fading effect. Default value is 400 milliseconds Possible values:
|
easing | Optional. Specifies the speed of the element in different points of the effect. Default value is "swing" Possible values:
|
callback | Optional. A function to be executed after the fadeToggle() method is completed
To learn more about callback, please read our jQuery Callback chapter |
The finish() method stops the currently-running animations, removes all queued animations, and completes all animations for the selected elements.
This method is similar to the .stop(true,true) method, except that finish() also causes the CSS property of all queued animations to stop.
$(selector).finish(queueName)
Parameter | Description |
---|---|
queueName | Optional. Specifies the name of the queue to stop animations |
The hide() method hides the selected elements.
This is similar to the CSS property display:none.
$(selector).hide(speed,easing,callback)
Parameter | Description |
---|---|
speed | Optional. Specifies the speed of the hide effect. Default value is 400 milliseconds Possible values:
|
easing | Optional. Specifies the speed of the element in different points of the animation. Default value is "swing" Possible values:
|
callback | Optional. A function to be executed after the hide() method is completed
To learn more about callback, visit our jQuery Callback chapter |
The queue() method shows the queue of functions to be executed on the selected elements. A queue is one or more function(s) waiting to run
number
$(selector).queue(queueName)
Parameter | Description |
---|---|
queueName | Optional. Specifies the name of the queue Default is "fx", the standard effects queue |
Display the length of a queue in a <span> element:
The show() method shows the hidden, selected elements.
Note: show() works on elements hidden with jQuery methods and display:none in CSS (but not visibility:hidden).
$(selector).show(speed,easing,callback)
Parameter | Description |
---|---|
speed | Optional. Specifies the speed of the show effect. Default value is 400 milliseconds Possible values:
|
easing | Optional. Specifies the speed of the element in different points of the animation. Default value is "swing" Possible values:
|
callback | Optional. A function to be executed after the show() method is completed
To learn more about callback, visit our jQuery Callback chapter |
Show all hidden <p> elements
The slideDown() method slides-down (shows) the selected elements
Note: slideDown() works on elements hidden with jQuery methods and display:none in CSS (but not visibility:hidden).
$(selector).slideDown(speed,easing,callback)
Parameter | Description |
---|---|
speed | Optional. Specifies the speed of the slide effect. Default value is 400 milliseconds Possible values:
|
easing | Optional. Specifies the speed of the element in different points of the animation. Default value is "swing" Possible values:
|
callback | Optional. A function to be executed after the slideDown() method is completed
To learn more about callback, visit our jQuery Callback chapter |
Slide-down (show) all hidden <p> elements:
The slideToggle() method toggles between slideUp() and slideDown() for the selected elements
This method checks the selected elements for visibility. slideDown() is run if an element is hidden. slideUp() is run if an element is visible - This creates a toggle effect.
$(selector).slideToggle(speed,easing,callback)
Parameter | Description |
---|---|
speed | Optional. Specifies the speed of the slide effect. Default value is 400 milliseconds Possible values:
|
easing | Optional. Specifies the speed of the element in different points of the animation. Default value is "swing" Possible values:
|
callback | Optional. A function to be executed after the slideToggle() method is completed
To learn more about callback, visit our jQuery Callback chapter |
Toggle between slideUp() and slideDown() for all <p> elements
The slideUp() method slides-up (hides) the selected elements
Note: Hidden elements will not be displayed at all (no longer affects the layout of the page)
$(selector).slideUp(speed,easing,callback)
Parameter | Description |
---|---|
speed | Optional. Specifies the speed of the slide effect. Default value is 400 milliseconds Possible values:
|
easing | Optional. Specifies the speed of the element in different points of the animation. Default value is "swing" Possible values:
|
callback | Optional. A function to be executed after the slideUp() method is completed
To learn more about callback, visit our jQuery Callback chapter |
Slide-up (hide) all <p> elements
The stop() method stops the currently running animation for the selected elements.
$(selector).stop(stopAll,goToEnd)
Parameter | Description |
---|---|
stopAll | Optional. A Boolean value specifying whether or not to stop the queued animations as well. Default is false |
goToEnd | Optional. A Boolean value specifying whether or not to complete all animations immediately. Default is false |
The toggle() method toggles between hide() and show() for the selected elements
This method checks the selected elements for visibility. show() is run if an element is hidden. hide() is run if an element is visible - This creates a toggle effect.
Note: Hidden elements will not be displayed at all (no longer affects the layout of the page).
$(selector).toggle(speed,easing,callback)
Parameter | Description |
---|---|
speed | Optional. Specifies the speed of the hide/show effect Possible values:
|
easing | Optional. Specifies the speed of the element in different points of the animation. Default value is "swing" Possible values:
|
callback | Optional. A function to be executed after the toggle() method is completed To learn more about callback, visit our jQuery Callback chapter |
Toggle between hide and show for all <p> elements
We will learn about html references in next chapter Click