jQuery
HTML
CSS
JavaScript
PHP
SQL
WordPress
jQuery Reference

Quick Reference

The animate() method performs a custom animation on an HTML element, changing one CSS property value to another gradually, creating an animated effect.

  • Only numeric values can be animated (“margin: 10px”)
  • String values cannot be animated (“background-color: red”)
  • “+=” or “-=” can be used for relative animations
				
					$('div').animate();
				
			

Syntax

				
					(selector).animate({styles}, speed, easing, callback)
				
			
				
					$('button').click(function() {
    $('div').animate({opacity: '0.2'}, 'slow', 'swing');
});
				
			

Parameters

ParameterDescription
stylesSpecifies one or more CSS properties/values to animate; the property names must be camel-cased when used with the animate() method (paddingLeft instead of padding-left, marginRight instead of margin-right, etc.) (required)

Only numeric values can be animated (like “margin: 20px”); string values cannot be animated (like “background-color: red”).

Properties that can be animated:
  • backgroundPositionX
  • backgroundPositionY
  • borderWidth
  • borderBottomWidth
  • borderLeftWidth
  • borderRightWidth
  • borderTopWidth
  • borderSpacing
  • margin
  • marginBottom
  • marginLeft
  • marginRight
  • marginTop
  • opacity
  • outlineWidth
  • padding
  • paddingBottom
  • paddingLeft
  • paddingRight
  • paddingTop
  • height
  • width
  • maxHeight
  • maxWidth
  • minHeight
  • minWidth
  • fontSize
  • bottom
  • left
  • right
  • top
  • letterSpacing
  • wordSpacing
  • lineHeight
  • textIndent
speedSpecifies the speed of the animation; possible values (default value is 400 milliseconds):
milliseconds (like 100, 1000, 5000, etc)
  • “slow”
  • “fast”
easingOptional. Specifies the speed of the element in different points of the animation; possible values:

  • “swing” – moves slower at the beginning/end, but faster in the middle (defaul)

  • “linear” – moves in a constant speed

callbackA function to be executed after the animation completes

We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.

jQuery
HTML
CSS
JavaScript
PHP
SQL
WordPress

Why 1SMARTchicken?

This site was built and is maintained to benefit my autistic son.
See More →

My Son's Name is Johnny

He was diagnosed as autistic quite late, at age four...
His story

Buy Me a Coffee

Thanks for your support!

Feedback

If you see an error on the page or the code itself is incorrect or incomplete, or just plain wrong, please let us know. We’re always learning. NOTE: we do not sell your information and will not send you spam emails.