queue()方法是jQuery中的一个内置方法,用于显示要在选定元素上执行的函数队列。在队列中,一个或多个函数等待运行。
null
- queue()方法可以与dequeue()方法一起使用。
- 一个元素可能有几个队列。通常只有一个默认的jQuery队列。
语法:
$(selector).queue(queue_name)
参数: 此方法接受单个参数 队列名称 这是可选的。它用于设置队列名称。
下面的示例演示了jQuery中的queue()方法:
例子:
<!DOCTYPE html> < html > < head > < title >The queue Method</ title > < script src = </ script > <!-- jQuery code to show the working of this method --> < script > $(document).ready(function() { $("p").click(function() { var div = $("div"); div.animate({ left: "+=200" }, 2000); div.animate({ height: 200 }, "slow"); div.animate({ width: 150 }, "slow"); div.animate({ height: 100 }, "slow"); div.animate({ width: 60 }, "slow"); div.animate({ left: "-=200", top: "+=100" }, 2000); $("span").text(div.queue().length); }); }); </ script > < style > div { width: 50px; height: 50px; position: absolute; left: 35px; margin-top: 10px; background-color: green; } body { width: 500px; height: 250px; border: 2px solid green; padding: 20px; } </ style > </ head > < body > < p >The queue length is: < span ></ span ></ p > <!-- click on above paragraph to show the number of times animation method works --> < div ></ div > </ body > </ html > |
输出: 在单击段落元素之前: 单击段落元素后:
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END