码迷,mamicode.com
首页 > Web开发 > 详细

jQuery clearQueue

时间:2014-08-27 14:23:07      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   java   io   strong   ar   art   

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>

 

jQuery clearQueue

标签:style   blog   color   os   java   io   strong   ar   art   

原文地址:http://www.cnblogs.com/sntetwt/p/3939189.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!