slideDown() Method - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:slideDown

Description

The slideDown() method slides-down to show the selected elements.

Syntax

$(selector).slideDown(speed,easing,callback);
Parameter Require Description Value
speed Optional. speed of the slide effect. Default value is 400 milliseconds Possible values: milliseconds "slow" "fast"
easingOptional. speed of the element in different points of the animation. Default value is "swing"
callback Optional.A function to be executed after the slideDown() method is completed a function

Possible easing values:

  • "swing" - slower at the beginning/end, but faster in the middle
  • "linear" - in a constant speed

The following code shows how to slide-down to show all hidden <p> elements:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $(".btn1").click(function(){
        $("p").slideUp();
    });//from ww w.j a va2 s  .c  o  m
    $(".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>

Related Tutorials