jQuery clearQueue() 方法
实例
停止队列中剩余的函数:
<!DOCTYPE html><html><head><script src="https://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script><script>$(document).ready(function(){$("#start").click(function(){$("div").animate({height: 300}, 1500);$("div").animate({width: 300}, 1500);$("div").animate({height: 100}, 1500);$("div").animate({width: 100}, 1500);});$("#stop").click(function(){$("div").clearQueue();});});</script></head><body><button id="start">开始动画</button><button id="stop">停止动画</button><br><br><div style="background:red;height:100px;width:100px;"></div></body></html>
定义与用法
clearQueue() 方法从队列中删除尚未运行的所有项。请注意,当函数开始运行时,它会一直运行到完成。
相关方法:
提示: 与 stop() 方法(仅适用于动画)不同,clearQueue() 方法可以删除任何队列函数。
语法
$(selector).clearQueue(queueName)
| 参数 | 描述 |
|---|---|
| queueName | 可选。指定队列的名称 默认值是 "fx", 标准效果队列 |