jquery clearQueue方法 语法

jquery clearQueue方法 语法

作用:clearQueue() 方法停止队列中所有仍未执行的函数。与 stop() 方法不同,(只适用于动画),clearQueue() 能够清除任何排队的函数(通过 .queue() 方法添加到通用 jQuery 队列的任何函数)。
无锡大理石测量平台

语法:$(selector).clearQueue(queueName)

参数:大理石平台生产厂

参数 描述
queueName 可选。规定要停止的队列的名称。默认是 "fx",标准效果队列。

jquery clearQueue方法 示例

<html>
<head>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript"> 
$(document).ready(function(){
  $("#start").click(function(){
    $("#box").animate({height:300},"slow");
    $("#box").animate({300},"slow");
    $("#box").queue(function () {
      $(this).css("background-color","red");  
      $(this).dequeue();
    });
    $("#box").animate({height:100},"slow");
    $("#box").animate({100},"slow");
  });
  $("#stop").click(function(){
    $("#box").clearQueue();
  });
});
</script>
</head>
<body>

<p><button id="start">Start Animation</button><button id="stop">Stop Animation</button></p>
<div id="box" style="background:#98bf21;height:100px;100px;position:relative">
</div>
</body>
</html>
原文地址:https://www.cnblogs.com/furuihua/p/11982782.html