如何在事件单击弹出窗口关闭时重置 setInterval 函数
How to reset setInterval function on event click on popup close
<script>
$(document).ready(function () {
setInterval(function () {
$.magnificPopup.open({
items: {
src: '#test-popup'
},
type: 'inline'
});
}, <?php echo $time_popup; ?>);
});
</script>
这是我的脚本。当单击关闭弹出窗口时,我尝试重置设置间隔功能。我使用 magnific popup,尝试 this,没有结果。
您必须将 setInterval
调用分配给变量才能使用 clearInterval
重置它。
var timer = setInterval(function() {
// Your stuff.
clearInterval(timer);
});
The clearInterval()
method clears a timer set with the setInterval()
method.
The ID value returned by setInterval()
is used as the parameter for the clearInterval()
method.
<script>
$(document).ready(function () {
setInterval(function () {
$.magnificPopup.open({
items: {
src: '#test-popup'
},
type: 'inline'
});
}, <?php echo $time_popup; ?>);
});
</script>
这是我的脚本。当单击关闭弹出窗口时,我尝试重置设置间隔功能。我使用 magnific popup,尝试 this,没有结果。
您必须将 setInterval
调用分配给变量才能使用 clearInterval
重置它。
var timer = setInterval(function() {
// Your stuff.
clearInterval(timer);
});
The
clearInterval()
method clears a timer set with thesetInterval()
method.The ID value returned by
setInterval()
is used as the parameter for theclearInterval()
method.