-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
36 lines (31 loc) · 901 Bytes
/
script.js
File metadata and controls
36 lines (31 loc) · 901 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
28
29
30
31
32
33
34
35
36
document.addEventListener("DOMContentLoaded", function () {
var inputField = document.getElementById("inputField");
var button = document.getElementById("dynamicButton");
var isLoading = false;
inputField.addEventListener("input", function () {
if (this.value) {
this.classList.add("filled");
} else {
this.classList.remove("filled");
}
});
inputField.addEventListener("blur", function () {
if (!this.value) {
this.classList.remove("focused");
}
});
inputField.addEventListener("focus", function () {
this.classList.add("focused");
});
button.addEventListener("click", function () {
if (!isLoading) {
isLoading = true;
button.classList.add("loading");
setTimeout(function () {
button.classList.remove("loading");
button.disabled = true;
isLoading = false;
}, 2000);
}
});
});