Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道在使用 setInterval 之后是否真的可以显式停止功能。
<script> setInterval(function(){document.write("Hello");},1000); </script>
使用clearInterval():
clearInterval()
var timer = setInterval(function(){ document.write("Hello"); if (someCondition) { clearInterval(timer); // this stops the interval } },1000);