clearInterval() 예제
<p id="demo"></p> <button onclick="homzzang()">시간 정지</button> <script> var hzVar = setInterval(hzTimer, 1000); function hzTimer() { var d = new Date(); var t = d.toLocaleTimeString(); document.getElementById("demo").innerHTML = t; } function homzzang() { clearInterval(hzVar); } </script> 결과보기
<p id="demo"></p>
<button onclick="homzzang()">시간 정지</button>
<script>
var hzVar = setInterval(hzTimer, 1000);
function hzTimer() {
var d = new Date();
var t = d.toLocaleTimeString();
document.getElementById("demo").innerHTML = t;
}
function homzzang() {
clearInterval(hzVar);
</script>
결과보기