-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
34 lines (30 loc) · 1003 Bytes
/
script.js
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
const variableText = document.querySelector(".variable-text");
const variableTextLoad = () => {
setTimeout(() => {
variableText.textContent = "Suisei "
},0)
setTimeout(() => {
variableText.textContent = "Kirby "
},4000)
setTimeout(() => {
variableText.textContent = "Yumi "
},8000)
}
variableTextLoad();
setInterval(variableTextLoad, 12000);
const btn = document.querySelector("#submit");
const changes = document.querySelectorAll(".change");
const input = document.querySelector("#name");
btn.addEventListener("click", (e) => {
if (input && input.value) { /* Check to see if it's empty*/
changes.forEach((change) => {
e.preventDefault();
change.innerText = input.value;
})
} else { /*Make the default value "Suisei" if there's no input*/
changes.forEach((change) => {
e.preventDefault();
change.innerText = 'Suisei';
})
}
});