jQuery queue() 方法
实例
在 <span> 元素中显示队列的长度:
<!DOCTYPE html><html><head><script src="https://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script><script>$(document).ready(function(){$("button").click(function(){var div = $("div");div.animate({height: 300}, "slow");div.animate({width: 300}, "slow");div.animate({height: 100}, "slow");div.animate({width: 100}, "slow");$("span").text(div.queue().length);});});</script></head><body><button>开始动画</button><p>队列的长度: <span></span></p><div style="width:50px;height:50px;position:absolute;left:10px;top:100px;background-color:red;"></div></body></html>
定义与用法
queue() 方法显示要在选定元素上执行的函数队列。
所谓队列是一个或多个等待运行的函数。
queue() 方法可以与 dequeue() 方法一起使用。
一个元素可以有几个队列。但通常它只有一个 "fx" 队列,这是默认的 jQuery 队列。
语法
$(selector).queue(queueName)
| 参数 | 描述 |
|---|---|
| queueName | 可选。默认队列名称 默认值是 "fx", 标准队列 |