-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
27 lines (24 loc) · 758 Bytes
/
app.js
File metadata and controls
27 lines (24 loc) · 758 Bytes
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
const inputs = document.querySelectorAll(".contact-input");
const toggleBtn = document.querySelector(".theme-toggle");
const allElements = document.querySelectorAll("*");
toggleBtn.addEventListener("click", () => {
document.body.classList.toggle("dark");
allElements.forEach((el) => {
el.classList.add("transition");
setTimeout(() => {
el.classList.remove("transition");
}, 1000);
});
});
inputs.forEach((ipt) => {
ipt.addEventListener("focus", () => {
ipt.parentNode.classList.add("focus");
ipt.parentNode.classList.add("not-empty");
});
ipt.addEventListener("blur", () => {
if (ipt.value == "") {
ipt.parentNode.classList.remove("not-empty");
}
ipt.parentNode.classList.remove("focus");
});
});