XML/HTML代码
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>jQuery制作从左到右从新排列内容动画特效</title>
- <style>
- body{ height: 3000px; padding: 0; margin: 0; }
- div{ background: #000; margin: 20px 0; width: 100px; height: 30px; color: #fff; line-height: 30px; text-align: center; }
- </style>
- </head>
- <script src="js/jquery.min.js"></script>
- <body>
- <div class="op1">111</div>
- <div class="op2">222</div>
- <div class="op3">333</div>
- <div class="op4">444</div>
- <div class="op5">555</div>
- <div class="op6">666</div>
- <div class="op7">777</div>
- <input type="button" value="stop!!!" />
- <script>
- var _width = ($(document).width() - $('div').width()) + "px";
- var animateList=[
- function(){ $('.op1').delay(500).animate({marginLeft:_width},500,queueList); },
- function(){ $('.op2').delay(300).animate({marginLeft:_width},500,queueList); },
- function(){ $('.op3').delay(300).animate({marginLeft:_width},500,queueList); },
- function(){ $('.op4').delay(700).animate({marginLeft:_width},500,queueList); },
- function(){ $('.op5').delay(300).animate({marginLeft:_width},500,queueList); },
- function(){ $('.op6').delay(200).animate({marginLeft:_width},500,queueList); },
- function(){ $('.op7').delay(300).animate({marginLeft:_width},500,function(){ alert('动画队列结束'); } );}
- ];
- $(document).queue('_queueList',animateList);
- var queueList=function(){
- $(document).dequeue('_queueList');
- };
- queueList();
- $(':button').click(function(){
- $(document).clearQueue('_queueList');
- });
- </script>
- </body>
- </html>