The clearQueue() method is combined with the clearQueue() method;
.clearQueue() can be used to remove any function added to a generic jQuery sequence via the .queue() method .
Example:
<!DOCTYPE html> <html> <head> <style> p { margin:3px; width:40px; height:40px; position:absolute; left:0px; top:30px; background:green; display:none; } p.newcolor { background:blue; } </style> <script type="text/javascript" src="/jquery/jquery.js"></script> </head> <body> <button id="start">开始</button> <button id="stop">停止</button> <p></p> <script> $("#start").click(function () { $("p").show("slow"); $("p").animate({left:'+=200'},5000); $("p").queue(function () { $(this).addClass("newcolor"); $(this).dequeue(); }); $("p").animate({left:'-=200'},1500); $("p").queue(function () { $(this).removeClass("newcolor"); $(this).dequeue(); }); $("p").slideUp(); }); $("#stop").click(function () { $("p").clearQueue(); $("p").stop(); }); </script> </body> </html>
The above is the detailed content of jQuery clearQueue related introduction and examples. For more information, please follow other related articles on the PHP Chinese website!