如何在选项卡更改时停止 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/