javascript - clearInterval 不能从 setTimeout 内的间隔工作
问题描述
清除间隔不适用于我在 setTimeout() 中使用的间隔。
var $scroller;
setTimeout(function() {
var div = jQuery('.module-content-slider');
$scroller = setInterval(function(){
/* interval function */
}, 25)
}, 1000);
clearInterval($scroller);
解决方案
在 1 秒(毫秒)后的 "" 内clearInterval
运行之前的运行 - 有效地清除未设置的间隔。setInterval
timeout
1000
$scroller
推荐阅读
- amazon-web-services - 5 分钟后 AWS DMS(数据迁移服务)表完全加载超时
- c# - Unity将www.text转换为字典以访问值?
- java - 为什么这个带有泛型的代码会在 Java 11 中引发 ClassCastException?
- c# - 在 Azure EventHubTrigger 函数应用中设置列
- oracle-sqldeveloper - SQL开发人员中的Ords安装问题
- java - 使用 Stream...peek() 生成变量的测试方法
- sql - 构建多个子查询结果的总和
- python - Python 子进程返回非零退出状态 1. 最小工作示例
- powershell - TravisCI 中的 Powershell 测试因缺少 RequiredModules 而失败
- python - 创建对象以进行测试的一些 Django 最佳实践是什么