</>
Skip to content
jQuery lessons (10/39)

jQuery — Slide

slideDown()

$("p").slideDown();
$("p").slideDown(400);
$("p").slideDown("slow");

slideUp()

$("p").slideUp();
$("p").slideUp(400);
$("p").slideUp("fast");

slideToggle()

$("p").slideToggle(400);
$("p").slideToggle("slow");

Practical: Accordion

<button class="accordion">Section 1</button>
<div class="panel">
    <p>Content for section 1</p>
</div>
<button class="accordion">Section 2</button>
<div class="panel">
    <p>Content for section 2</p>
</div>

<script>
$(document).ready(function() {
    $(".accordion").click(function() {
        $(this).next(".panel").slideToggle(300);
    });
});
</script>

CSS Setup for Slides

.panel {
    display: none;
    overflow: hidden;
}

Show/Hide Content

$("#showBtn").click(function() {
    $("#content").slideDown(300);
});

$("#hideBtn").click(function() {
    $("#content").slideUp(300);
});

$("#toggleBtn").click(function() {
    $("#content").slideToggle(300);
});

Mini Practice

  1. Create a slideDown reveal on button click
  2. Build a simple accordion with slideToggle
  3. Slide a panel up when clicking outside
  4. Combine slide with fade effects

Up Next

Continue with Animate — custom animations with animate().

Related Topics

Frequently Asked Questions about Slide

What is Slide in jQuery?

Slide is a fundamental concept in jQuery. This lesson explains it step by step with clear examples, making it easy for beginners to understand.

How do I learn Slide?

Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Slide.

Why is Slide important in jQuery?

Slide is essential for jQuery development. Understanding this concept will help you write better code and solve real-world problems more effectively.