jQuery Animation How to - Slide to hide








Question

We would like to know how to slide to hide.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.10.1.js'></script>
<script type='text/javascript'>
$(window).load(function(){<!--from  www.j a  v  a 2 s .  co m-->
    $(document).ready(function () {
        $('.show_hide').click(function () {
            $('.slidingDiv').slideToggle('fast');
        });
    });
});
</script>
</head>
<body>
  <div class="slidingDiv" style="display: none;">Sliding Div</div>
  <button class="show_hide">Show/Hide</button>
</body>
</html>

The code above is rendered as follows: