Animations
4 min read Quiz at the end
Built-in effects include hide(), show(), fadeIn(), fadeOut(), slideDown(), and slideToggle(). Pass a duration in milliseconds or 'slow'/'fast'. Add a callback function that runs when the animation finishes.
Built-in Animations $('#box').hide();
$('#box').show();
$('#box').toggle();
$('#box').fadeIn(500);
$('#box').fadeOut('slow');
$('#box').fadeToggle();
$('#box').slideDown(300);
$('#box').slideUp();
$('#box').slideToggle();
Topic Quiz · 5 questions
Test your understanding before moving on
1. Which method shows a hidden element with fade?
A. .show()
B. .appear()
C. .fadeIn()
D. .visible()
💡 .fadeIn() shows a hidden element by gradually increasing its opacity.
2. Which method hides an element by sliding up?
A. .hide()
B. .slideUp()
C. .collapseUp()
D. .shrink()
💡 .slideUp() hides an element by sliding it upward.
3. What does .toggle() do?
A. Changes class
B. Alternates show/hide
C. Fades in and out
D. Rotates element
💡 .toggle() shows the element if hidden, hides it if visible.
4. Which parameter controls animation speed?
A. A number in ms or 'slow'/'fast'
B. Only 'slow'/'fast'
C. Only numbers
D. A percentage
💡 Animation speed accepts milliseconds (e.g. 500) or strings ('slow', 'fast').
5. What does .stop() do?
A. Removes element
B. Pauses the page
C. Stops the current animation
D. Clears queue
💡 .stop() stops the currently running animation on matched elements.
Submit answers