Showing or Hiding Content with jQuery Animation
jQuery makes it super easy to animate content visibility with built-in methods like .show(), .hide(), and .toggle() — all of which support smooth animation effects.
✅ What You’ll Learn
-
How to show, hide, or toggle content
-
How to animate the speed
-
Bonus: Use
.slideDown(),.slideUp(),.fadeIn(),.fadeOut()for fancier effects
Basic HTML Example
Basic jQuery Toggle Animation
.toggle(speed)will show the element if it’s hidden, and hide it if it’s visible — with animation.
Other jQuery Animation Methods
| Method | Description |
|---|---|
.show(speed) |
Animates showing the element |
.hide(speed) |
Animates hiding the element |
.toggle(speed) |
Toggles show/hide with animation |
.slideDown() |
Slide down to show |
.slideUp() |
Slide up to hide |
.fadeIn() |
Fade in (good for smooth reveals) |
.fadeOut() |
Fade out |
Example: Slide Animation
Example: Fade In/Out
Tip: Change Button Text Dynamically
Summary
| jQuery Method | Use for… |
|---|---|
.show() / .hide() |
Simple appear/disappear |
.slideDown() / .slideUp() |
Slide effects |
.fadeIn() / .fadeOut() |
Fade effects |
.toggle() / .fadeToggle() / .slideToggle() |
Toggle with animation |
