-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtitle.html
52 lines (42 loc) · 920 Bytes
/
title.html
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html>
<html>
<head>
<title>AlgoHub</title>
<style>
</style>
</head>
<body>
<div class="typing">
<h1></h1>
</div>
</body>
<script>
var text = document.querySelector('.typing h1');
var words = ['Iset Camp', 'Algo Hub'];
let wordIndex = 0;
let letterIndex = 0;
function type() {
if (letterIndex < words[wordIndex].length) {
text.textContent += words[wordIndex].charAt(letterIndex);
letterIndex++;
setTimeout(type, 200);
} else {
setTimeout(erase, 1000);
}
}
function erase() {
if (letterIndex > 0) {
text.textContent = words[wordIndex].substring(0, letterIndex - 1);
letterIndex--;
setTimeout(erase, 100);
} else {
wordIndex++;
if (wordIndex >= words.length) {
wordIndex = 0;
}
setTimeout(type, 500);
}
}
setTimeout(type, 1000);
</script>
</html>