XML/HTML代码
  1. <!doctype html>  
  2. <html lang="en">  
  3. <head>  
  4.     <meta charset="UTF-8">  
  5.     <title>jQuery制作从左到右从新排列内容动画特效</title>  
  6.     <style>  
  7.     body{ height: 3000px; padding: 0; margin: 0; }  
  8.     div{ background: #000; margin: 20px 0; width: 100px; height: 30px; color: #fff; line-height: 30px; text-align: center; }  
  9.     </style>  
  10. </head>  
  11.  <script src="js/jquery.min.js"></script>  
  12.  <body>  
  13.     <div class="op1">111</div>  
  14.     <div class="op2">222</div>  
  15.     <div class="op3">333</div>  
  16.     <div class="op4">444</div>  
  17.     <div class="op5">555</div>  
  18.     <div class="op6">666</div>  
  19.     <div class="op7">777</div>  
  20.     <input type="button" value="stop!!!" />  
  21.     <script>  
  22.     var _width = ($(document).width() - $('div').width()) + "px";  
  23.   
  24.     var animateList=[   
  25.           function(){ $('.op1').delay(500).animate({marginLeft:_width},500,queueList);  },   
  26.           function(){ $('.op2').delay(300).animate({marginLeft:_width},500,queueList);  },   
  27.           function(){ $('.op3').delay(300).animate({marginLeft:_width},500,queueList);  },   
  28.           function(){ $('.op4').delay(700).animate({marginLeft:_width},500,queueList);  },   
  29.           function(){ $('.op5').delay(300).animate({marginLeft:_width},500,queueList);  },   
  30.           function(){ $('.op6').delay(200).animate({marginLeft:_width},500,queueList);  },   
  31.           function(){ $('.op7').delay(300).animate({marginLeft:_width},500,function(){ alert('动画队列结束'); } );}  
  32.     ];   
  33.       
  34.     $(document).queue('_queueList',animateList);   
  35.     var queueList=function(){   
  36.         $(document).dequeue('_queueList');   
  37.     };   
  38.     queueList();  
  39.   
  40.     $(':button').click(function(){  
  41.         $(document).clearQueue('_queueList');  
  42.     });  
  43.   
  44.     </script>  
  45.   
  46. </body>  
  47. </html>  

 

H5/JS/CSS | 评论(0) | 引用(0) | 阅读(3953)