-2
실시간 시계를 만들려고했지만 문제가 있습니다. setTimeout은 실제로 시계가 작동하지 않고 시계 자체가 업데이트되지 않습니다. 도와 드릴까요? 그러나 당신이 그것을 그렇게 결코 업데이트, 함수의 currentDate
외부의 인스턴스를,이 Javascript 실시간 시계에서 setTimeout을 어떻게 사용해야합니까?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<p id="p"></p>
<script>
var currentDate = new Date();
function startClock() {
time = currentDate.getHours() + ":" + currentDate.getMinutes() + ":" + currentDate.getSeconds();
document.getElementById("p").innerHTML = time;
setTimeout(startClock, 1000);
}
startClock();
</script>
</body>
</html>
당신이 또한 설명 할 수 있을까? – Pier
probs, 나는 그것을 추가했습니다. 그걸 정리 해줄 수 있니? – user184994