The snippet library.
Small, practical examples. Search by task or narrow things down below.
Animate a numeric CSS property
jQuery: animate interpolates supported numeric properties to their final values.
jQuery✓ Tested
Animate relative to the current value
jQuery: A plus-equals value adds to the current numeric CSS value.
jQuery✓ Tested
Collapse a panel after an animation
jQuery: slideUp hides the panel when the transition completes.
jQuery✓ Tested
Disable animations for a reduced-motion mode
jQuery: The global fx.off switch causes effects to finish immediately.
jQuery✓ Tested
Fade a hidden element into view
jQuery: fadeIn shows a hidden element and calls its completion handler.
jQuery✓ Tested
Fade an element out and hide it
jQuery: fadeOut sets display none after the opacity animation finishes.
jQuery✓ Tested
Finish all queued animations immediately
jQuery: finish jumps current and queued animations to their final values.
jQuery✓ Tested
Reveal a collapsed panel with a slide
jQuery: slideDown animates the panel’s vertical dimensions.
jQuery✓ Tested
Stop current animation and discard later work
jQuery: stop with clearQueue and jumpToEnd finishes the current animation and removes pending ones.
jQuery✓ Tested
Wait until all selected elements finish animating
jQuery: promise observes the animation queues for every matched element.
jQuery✓ Tested