jQuery clearQueue
时间:2014-08-27 14:23:07
收藏:0
阅读:294
clearQueue()方法与clearQueue()方法结合;
.clearQueue()可用于删除通过.queue()方法添加到通用jQuery序列的任何函数。
示例:
<!DOCTYPE html> <html> <head> <style> div { margin:3px; width:40px; height:40px; position:absolute; left:0px; top:30px; background:green; display:none; } div.newcolor { background:blue; } </style> <script type="text/javascript" src="/jquery/jquery.js"></script> </head> <body> <button id="start">开始</button> <button id="stop">停止</button> <div></div> <script> $("#start").click(function () { $("div").show("slow"); $("div").animate({left:‘+=200‘},5000); $("div").queue(function () { $(this).addClass("newcolor"); $(this).dequeue(); }); $("div").animate({left:‘-=200‘},1500); $("div").queue(function () { $(this).removeClass("newcolor"); $(this).dequeue(); }); $("div").slideUp(); }); $("#stop").click(function () { $("div").clearQueue(); $("div").stop(); }); </script> </body> </html>
原文:http://www.cnblogs.com/sntetwt/p/3939189.html
评论(0)