-
Notifications
You must be signed in to change notification settings - Fork 1
/
HappyBirthday.html
55 lines (47 loc) · 1.45 KB
/
HappyBirthday.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
53
54
55
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<title>Happy birthday! | adentent.github.io</title>
<link rel="stylesheet" href="./styles.css">
<link rel="stylesheet" href="./HappyBirthday.css">
</head>
<body>
<span class="text">
<p>Hello!</p>
<p>Happy Birthday!</p>
<p>At Sun Feb 11 2024, your birthday, hope you will have <b>a good day</b>!</p>
</span>
<script>
const text = document.querySelector('.text');
const txt = ["Hello!",
"Happy Birthday!",
"At Sun Feb 11 2024, your birthday, hope you will have <b>a good day</b>!",
"Maybe it look simple, but hard to make!",
"Have a good day anyway!"];
var index = 0;
var xiaBiao = 0;
var huan = true;
setInterval(function () {
if (huan) {
text.innerHTML = txt[xiaBiao].slice(0, ++index);
console.log(index);
}
else {
text.innerHTML = txt[xiaBiao].slice(0, index--);
console.log(index);
}
if (index == txt[xiaBiao].length + 3) {
huan = false;
}
else if (index < 0) {
index = 0;
huan = true;
xiaBiao++;
if (xiaBiao >= txt.length) {
xiaBiao = 0;
}
}
}, 60)
</script>
</body>