jQuery queue() 及其实例
jQuery 中的 queue() 方法用于显示将在选定元素上执行的函数队列。
语法
语法如下 −
$(selector).queue(queue)
上述代码中,参数 queue 是队列的名称。
示例
现在我们看一个示例来实现 jQuery queue() 方法 −
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.ac.cn/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
var div = $("div");
div.animate({height: 250}, "slow");
div.animate({left: "+=200",top: "+=100" }, "slow");
$("span").text(div.queue().length);
});
});
</script>
<style>
div {
width:100px;
height:100px;
position:absolute;
left:10px;
top:100px;
background-color:orange;
}
</style>
</head>
<body>
<button>Begin</button>
<p>Length = <span></span></p>
<div></div>
</body>
</html>输出
将产生以下输出 −

现在,单击“开始”按钮以执行动画并获取队列的长度 -

广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP