why use onclick="slide()" if you want a slide at the click of a button do the following
CSS
#box { position: absolute; width: 120px; height: 100px; background: #ff0000; left: 500px; }
HTML (assign some identifier)
<button id="slide">slide</button> <div id="box">whetever</div>
JQuery
<script type='text/javascript'> $(document).ready(function (){ $('button#slide').click(function(){ $('#box').animate({'left': 0},3000); }); }); </script>
Smoother animations
Additionally, jQuery now uses the new requestAnimationFrame method provided by browsers to make animations even smoother. We can use this functionality to avoid calling timers and instead depend on the browser to provide the best possible animation.
.promise()
Like $.ajax() before this, $.animate() gets $.animate() . JQuery objects can now return Promise for observation when all animations in the collection are complete:
$(".elements").fadeOut(); $.when( $(".elements") ).done(function( elements ) {
HAPPY HELP :)
source share