jQuery Method How to - Slide up and down with slideToggle('slow')








Question

We would like to know how to slide up and down with slideToggle('slow').

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.9.1.js'></script>
<script type='text/javascript'>
$(window).load(function(){<!--from w  ww.ja va2s .com-->
    $("#test").click(function() {
        $("#slideTest").slideToggle("slow");
    });
});
</script>
</head>
<body>
  <div id="slideTest">Slide me up!</div>
  <br />
  <br />
  <input type="button" value="Click me!" id="test" />
</body>
</html>

The code above is rendered as follows: