-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
58 lines (46 loc) · 1.16 KB
/
index.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const user = document.getElementById("user");
const loader = document.getElementById("loader");
const greeting = document.getElementById("greeting");
const box = document.getElementById("box");
function load(){
hide(loader);
}
function hide(element) {
element.classList.remove("block");
element.classList.add("none");
}
function display(element) {
element.classList.remove("none");
element.classList.add("block");
}
function toggle(element) {
display(element);
setTimeout(() => {
hide(element);
},5000)
}
function defineText(element, value) {
element.innerText = value;
}
//function hello() {
// alert("Hello World");
//}
//setTimeout(hello, 5000);
function greet(element, value) {
setTimeout(() => {
defineText(element, value);
display(element);
},5000)
}
window.addEventListener("keydown",(e) => {
if (e.key == "Enter") {
const username = user.value;
const text = "Hello " + username;
//4) hide(user);
//1) user.style.display = "none";
//2) user.remove();
//3) box.removeChild(user);
toggle(loader)
greet(greeting, text);
}
})