clearQueue()方法与clearQueue()方法结合;

.clearQueue()可用于删除通过.queue()方法添加到通用jQuery序列的任何函数

示例:


<!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>
登录后复制

以上就是jQuery clearQueue相关介绍及实例讲解的详细内容,更多请关注Work网其它相关文章!

09-16 10:49