Web
setTimeout 재귀함수
GOD03219
2018. 10. 19. 13:44
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 |
<html>
<title>10.19</title>
<head>
<script language="javascript">
var notice = "안녕하세요?"
var index = 0;
function showNotice() {
index++;
var div = document.getElementById("divClock");
if (index > notice.length) {
div.innerText = "";
index = 0;
} else div.innerText = notice.substr(0, index);
setTimeout(showNotice, 500);
}
</script>
</head>
<body onload="showNotice()">
<div id="divClock" class="clock"></div>
</body>
</html>
|
cs |