gpt4 book ai didi

javascript - 如何在选项卡更改时停止 jquery js 功能?

转载 作者:行者123 更新时间:2023-12-03 04:28:24 25 4
gpt4 key购买 nike

如何在选项卡更改时停止 jquery 功能?下面给出Jquery js函数的代码。

function move(){
addEventListener('load', function() {
createProgressbar('progressbar1', '40s', function() {
document.getElementById("close").style.display = "block";
document.getElementById("msg").style.display = "none";
});
});
}

有人可以帮我吗?如果需要任何其他信息,请发表评论。

最佳答案

请参阅下文以了解总体概念。

playing = function() {
foo = window.setInterval(function() {
console.log('as')
}, 500);
}

$(window).blur(function(e) {
clearInterval(foo);//clear the interval..which inturn stop execution
});

$(window).focus(function(e) {
//will get executed when current tab is focused
playing()
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
注意:运行代码片段后单击/退出输出区域以查看其工作情况。

关于javascript - 如何在选项卡更改时停止 jquery js 功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43602482/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com