jQuery Method How to - Use hide('slow') to hide div element slowly








Question

We would like to know how to use hide('slow') to hide div element slowly.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.6.2.js'></script>
<script type='text/javascript'>
$(function(){<!--  w ww.ja  v a  2  s  .c  om-->
    $('.close').click(function() {
        $('.alert-message').hide('slow');
    });
});
</script>
</head>
<body>
  <div class="alert-message success">
    <a class="close" style="">&times</a>
    <p>this is a message.</p>
  </div>
</body>
</html>

The code above is rendered as follows: