Toggle between sliding up and down the <div> element, when clicking the button in duration of 1000 milliseconds. - Javascript jQuery

Javascript examples for jQuery:Slide

Description

Toggle between sliding up and down the <div> element, when clicking the button in duration of 1000 milliseconds.

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(){
    $("button").click(function(){
        $("div").slideToggle(1000);
    });/*from   www  .ja  v a2  s .c  om*/
});
</script>
</head>
<body>

<button>Click to slide up/down div</button><br><br>

<div style="width:80px;height:80px;background-color:red;"></div>

</body>
</html>

Related Tutorials