jquery - 如何在鼠标悬停/悬停时暂停 setInterval() 函数?
问题描述
我无法找到暂停 setInterval() 的好解决方案。也许我以一种糟糕的方式建立了它,但我仍在学习。我想做的是在悬停/鼠标悬停时暂停 setInterval() 。我知道我将不得不以某种方式使用 clearInterval(),但我不知道如何。有人有任何提示吗?这就是我正在使用的:
var divs = $('.section').toArray();
function getsectionNext() {
divs.push(divs.shift());
return divs[0];}
function sectionInterval() {
setInterval(function() {
$('.section').removeClass('active');
$(getsectionNext()).addClass('active');
},10000);}
setInterval(sectionInterval());
非常感谢您为解决此问题提供的任何帮助!
解决方案
推荐阅读
- html - 从嵌套列填充可用空间 | 引导程序 4
- excel - 从个人工作簿运行时 Excel 宏不起作用
- r - 在将字符转换为 R 中的时间类型变量时,所有值都变为 NA
- django - 为什么 Django Visual Studio 代码中的前端更改不会立即在浏览器中执行
- c# - 与排序列表的数据绑定
- javascript - Ajax 调用成功函数触发两次
- javascript - React.js document.querySelectorAll() 不返回任何内容
- java - Jira 无法使用 Seraph SSO DefaultAuthenticator 更新上次登录时间
- c# - xamarin.ios 上的视图之间的翻译动画 [已解决]
- html - 如何在边框线之后(不在边框内)将图像附加到边框