jQuery slideDown() method is used to slide down an element.
Try it Yourself - Copy paste code in Online HTML Editor to see the result
Try it Yourself - Copy paste code in Online HTML Editor to see the result
Syntax
$(selector).slideDown(speed);
$(selector).slideDown(speed, callback);
$(selector).slideDown(speed, easing, callback);
- speed: It specifies the speed of the delay. Its possible values are slow, fast and milliseconds.
- easing: It specifies the easing function to be used for transition.
- callback: It is also an optional parameter. It specifies the function to be called after completion of slideDown() effect.
Example 1
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("#flip").click(function() {
$("#panel").slideDown("slow");
});
});
</script>
<style>
#panel,
#flip {
padding: 5px;
text-align: center;
background-color: #e5eecc;
border: solid 1px #c3c3c3;
}
#panel {
padding: 50px;
display: none;
}
</style>
</head>
<body>
<div id="flip">Click to slide down panel</div>
<div id="panel">Source Code Examples</div>
</body>
</html>
Example 2
Animates all divs to slide down and show themselves over 600 milliseconds.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>slideDown demo</title>
<style>
div {
background: #de9a44;
margin: 3px;
width: 80px;
height: 40px;
display: none;
float: left;
}
</style>
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
</head>
<body>
Click me!
<div></div>
<div></div>
<div></div>
<script>
$(document.body).click(function() {
if ($("div").first().is(":hidden")) {
$("div").slideDown("slow");
} else {
$("div").hide();
}
});
</script>
</body>
</html>
Comments
Post a Comment