jQuery slideDown()

Introduction

Slide-down and show all hidden <p> elements:

View in separate window

<!DOCTYPE html>
<html>
<head>
<script 
 src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>/*from   www .  j  av  a 2s .co m*/
<script>
$(document).ready(function(){
  $(".btn1").click(function(){
    $("p").slideUp();
  });
  $(".btn2").click(function(){
    $("p").slideDown();
  });
});
</script>
</head>
<body>

<p>This is a paragraph.</p>

<button class="btn1">Slide up</button>
<button class="btn2">Slide down</button>

</body>
</html>

The slideDown() method slides-down and shows the selected elements.

slideDown() works on elements hidden with jQuery methods and display:none in CSS but not visibility:hidden.

$(selector).slideDown(speed,easing,callback)
Parameter
Optional
Description
speed





Optional.





speed of the slide effect.
Default value is 400 milliseconds
Possible values:
milliseconds
"slow"
"fast"
easing




Optional.




speed of the element in different points of the animation.
Default value is "swing"
Possible values:
"swing" - moves slower at the beginning/end, faster in the middle
"linear" - moves in a constant speed
callback
Optional.
A function to be executed after the slideDown() method is completed



PreviousNext

Related