首页  >  文章  >  web前端  >  jQuery clearQueue相关介绍及实例讲解

jQuery clearQueue相关介绍及实例讲解

巴扎黑
巴扎黑原创
2017-06-20 15:06:091200浏览

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:&#39;+=200&#39;},5000);
  $("p").queue(function () {
    $(this).addClass("newcolor");
    $(this).dequeue();
  });
  $("p").animate({left:&#39;-=200&#39;},1500);
  $("p").queue(function () {
    $(this).removeClass("newcolor");
    $(this).dequeue();
  });
  $("p").slideUp();
});
$("#stop").click(function () {
  $("p").clearQueue();
  $("p").stop();
});
</script>


</body>
</html>

 

以上是jQuery clearQueue相关介绍及实例讲解的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn