To slide elements up and down with jQuery, you can use the slideUp()
and slideDown()
methods. Here's an example of how you can use them:
<div class="element">Content to slide</div>
<button id="slide-up">Slide Up</button>
<button id="slide-down">Slide Down</button>
.element {
display: none;
}
$(document).ready(function() {
$("#slide-up").click(function() {
$(".element").slideUp();
});
$("#slide-down").click(function() {
$(".element").slideDown();
});
});
In the above code, when the "Slide Up" button is clicked, the .element
div slides up and gets hidden using the slideUp()
method. When the "Slide Down" button is clicked, the .element
div slides down and becomes visible using the slideDown()
method.
Make sure you have included the jQuery library before using the above code.