加载中...

clearQueue()


概述    .clearQueue( [queueName ] )

返回值:jQuery

描述:从列队中移除所有未执行的项。

  • V : 1.4.clearQueue( [queueName ] )

    • queueName
      类型: String
      一个含有队列名的字符串。默认是fx,标准的效果队列。

.clearQueue()方法被访问的时候,所有在这个列队中未执行的函数将被移除 。当不使用参数的时候,.clearQueue()会从标准的动画队列fx中移除剩下的函数。这个方法类似.stop(true)。然而.stop()方法只适用在动画中。.clearQueue()还可以用来移除用.queue()方法添加到普通jQuery列表的任何函数。

示例

实例

清空列队

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <style>
  5. div { margin:3px; width:40px; height:40px;
  6. position:absolute; left:0px; top:30px;
  7. background:green; display:none; }
  8. div.newcolor { background:blue; }
  9. </style>
  10. <script src="http://code.jquery.com/jquery-latest.js"></script>
  11. </head>
  12. <body>
  13. <button id="start">Start</button>
  14. <button id="stop">Stop</button>
  15. <div></div>
  16. <script>
  17. $("#start").click(function () {
  18. var myDiv = $("div");
  19. myDiv.show("slow");
  20. myDiv.animate({left:'+=200'},5000);
  21. myDiv.queue(function () {
  22. var _this = $(this);
  23. _this.addClass("newcolor");
  24. _this.dequeue();
  25. });
  26. myDiv.animate({left:'-=200'},1500);
  27. myDiv.queue(function () {
  28. var _this = $(this);
  29. _this.removeClass("newcolor");
  30. _this.dequeue();
  31. });
  32. myDiv.slideUp();
  33. });
  34. $("#stop").click(function () {
  35. var myDiv = $("div");
  36. myDiv.clearQueue();
  37. myDiv.stop();
  38. });</script>
  39. </body>
  40. </html>

运行一下


还没有评论.