Jquery:stop(true) 和clearQueue() 有什么区别

标签 jquery

使用将 clearQueue 参数设置为 true 的 stop() 与仅使用 clearqueue() 之间有什么区别,以及如果没有区别为什么两者都一样?

最佳答案

从 API 文档来看,.stop() 仅适用于动画,但是 .clearqueue() 将删除附加到的任何函数一个标准的 jquery 队列。

来自docs :

When the .clearQueue() method is called, all functions on the queue that have not been executed are removed from the queue. When used without an argument, .clearQueue() removes the remaining functions from fx, the standard effects queue. In this way it is similar to .stop(true). However, while the .stop() method is meant to be used only with animations, .clearQueue() can also be used to remove any function that has been added to a generic jQuery queue with the .queue() method.

关于Jquery:stop(true) 和clearQueue() 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5466664/

相关文章:

jquery - 显示/隐藏 - jQuery 问题

javascript - jQuery 每 5 个工作小时重置一次颜色模式

jquery - 使用带有 Promise 的 jQuery 加载

javascript - 如何在 jquery 中使用 "For"而不是 "each"函数

javascript - AngularJS 动态内容在页面刷新时消失

javascript - 用变量替换 $(this) 是否会产生任何性能差异

javascript - 三个简单的 jQuery 步骤不起作用 - 设置变量、打印变量、比较变量

jquery - 如何使用 css 或 jquery 更改浏览器的默认滚动条

对话框内的 jquery 菜单不显示子菜单

jquery - 使用 Bootstrap 进度条作为倒计时器