TAG
JavaScript
Result
Run
License
<h1 id="watch"></h1> <button type="button" id="btn-cancel">동작 취소</button>
window.addEventListener("load", function() { var timerid; setTime(); timerid = window.setInterval(setTime, 1000); var elBtn = document.querySelector("#btn-cancel"); elBtn.addEventListener("click", function() { clearInterval(timerid); }); function setTime() { var d = new Date(); var elWatch = document.querySelector("#watch"); elWatch.textContent = d.toLocaleTimeString(); } });
Console
expand_less
License
License
by DevDic
Close