Animate div with jquery slide out - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:animate

Description

Animate div with jquery slide out

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.0.js"></script> 
  <script type="text/javascript">
    $(function(){//from www  .ja  v  a  2 s .com
var target = $('#targetDiv');
var left = '-'+ target.width() +'px';
target.animate({'margin-left': left },2000);
    });

      </script> 
 </head> 
 <body> 
  <div id="parentDiv"> 
   <div id="targetDiv" style="overflow:auto;height:20px;">
     this is lot of text 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials