이 기사에서는 JavaScript 타이머의 전체 구현 방법에 대해 설명합니다. 참조를 위해 공유하십시오. 특정 구현 방법은 다음과 같습니다.
다음과 같이 코드를 복사하십시오.
<html>
<헤드>
<meta http-equiv = "content-type"content = "text/html; charset = utf-8">
<title> 타이머 </제목>
<script type = "text/javaScript">
var timer = null;
함수 시작 () {
var date = 새 날짜 ();
var current_time = date.getsyear () + '-' + date.getmonth () + '-' + date.getDate () + '';
current_time + = date.gethours () + ':' + date.getMinutes () + ':' + date.getSeconds ();
document.getElementById ( 'current_time'). value = current_time;
타이머 = settimeout ( 'begin ()', 1000);
}
function end () {
클리어 타임 아웃 (타이머); // 타이머 개체를 지우십시오
}
</스크립트>
</head>
<body>
<입력 유형 = "text"name = "current_time"id = "current_time"/> <input type = "button"value = "start"onclick = "begin ();">
<입력 유형 = "버튼"value = "end"onclick = "end ();"/> <br/>
</body>
</html>
이 기사가 모든 사람의 JavaScript 프로그래밍에 도움이되기를 바랍니다.