本文共 1932 字,大约阅读时间需要 6 分钟。
元素可以有多个队列附加到它们上,我们可以为每个队列赋予不同的名称。我们可以 指定一个自定义队列名称 作为.queue()
方法的第一个参数。
官方文档:Elements can have multiple queues attached to them, and we can give each of these queues a different name. We can specify a custom queue name as the first argument to the .queue() method.
队列是 jQuery 中所有动画的基础,它们允许在一个元素上异步执行一系列函数,当使用.animate()
时,此方法会利用队列构建一系列步骤,这些步骤将在整个动画期间转换一个或多个CSS值。
官方文档:Queues are the foundation for all animations in jQuery, they allow a series functions to be executed asynchronously on an element. Methods such as .slideUp(), .slideDown(), .fadeIn(), and .fadeOut() all use .animate(), which leverages queues to build up the series of steps that will transition one or more CSS values throughout the duration of the animation.
jquery 对队列项的功能没有明确排序,因此我们需要调用 .dequeue()
,它告诉 jquery 何时移动到队列中的下一个项。因此,queue() 方法通常与 dequeue() 方法一起使用。
官方文档:jQuery does not have any insight into how the queue items function, so we need to call .dequeue(), which tells jQuery when to move to the next item in the queue.
queue(),dequeue(),clearQueue() queue() 方法允许你创建一个队列功能区执行被选中的元素。
dequeue() 方法顺序执行它们。
因为队列只是一组有序的操作,所以我们的应用程序可能有一些逻辑,需要防止剩余的队列条目继续执行。此方面可以通过调用 .clearQueue()
方法来实现这一点,该方法将清空对应的队列。
Since queues are just a set of ordered operations, our application may have some logic in place that needs to prevent the remaining queue entries from executing. We can do this by calling the .clearQueue() method, which will empty the queue.
与 .stop()
方法(只适用于动画)不同的是,.clearQueue()
方法移除任何排队的函数。
queue(),dequeue(),clearQueue() queue() 方法允许你创建一个队列功能区执行被选中的元素。
dequeue() 方法顺序执行它们。
queue(),dequeue(),clearQueue() queue() 方法允许你创建一个队列功能区执行被选中的元素。
dequeue() 方法顺序执行它们。
Reference
转载地址:http://sghwi.baihongyu.com/