This is an already available feature in the jQuery user interface. http://jqueryui.com/demos/show/ . This is how you do it.
<style type="text/css"> #mydiv{ width:300px; height:300px; background:red; display:none; margin-top:30px; } </style> <button>clickme</button> <div id="mydiv"></div> <script type="text/javascript"> $('button').click(function(){ $('#mydiv').toggle('bounce',300) }); </script>
I used toggle, which means that if you click on the button again, the effect will be read back to hide the field. You can use many available effects (blind, clip, drop, explosion, bend, highlight, puff, ripple, shake, slip, size, scale)
If you've never worked with jQuery before, make sure you include the necessary CSS and JS files.
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/start/jquery-ui.css" type="text/css" media="all" /> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js" type="text/javascript"></script>
source share