-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
56 lines (45 loc) · 1.45 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
const toastComponent = () => {
const btn = document.getElementById("btn-toast");
const toast = document.getElementById("show-toast");
const closeBtn = document.getElementById("close-btn");
let clicked = false;
const showToast = () => {
if(!clicked) {
clicked = true;
toast.style.display = "block";
setTimeout(() => {
toast.style.display = "none";
clicked = false;
}, 2000);
}
}
const closeToast = () => toast.style.display = "none";
btn.addEventListener("click", showToast);
closeBtn.addEventListener("click", closeToast);
}
toastComponent();
//addind and removing eventlistner
// const showToast = () => {
// toast.style.display = "block";
// btn.removeEventListener("click", showToast);
// setTimeout(() => {
// toast.style.display = "none";
// }, 2000);
// }
//tooltip
const closeTooltip = () => {
const btn = document.getElementById("close-btn-tooltip");
const tooltip = document.getElementById("close-text");
btn.addEventListener("mouseover", () => {
tooltip.style.display = "block";
})
btn.addEventListener("mouseleave", () => {
tooltip.style.display = "none"
})
const closeText = () => {
tooltip.style.display = "none";
}
btn.addEventListener("click", closeText);
tooltip.style.display = "block"; //it will reset the value to default
}
closeTooltip();