-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
33 lines (28 loc) · 940 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
const eye = document.getElementById("password-visibility");
const passInput = document.getElementById("pass");
const img = document.getElementById("bear");
const signInButton = document.querySelector(".signin");
let passwordVisible = true;
function changeImageOnClick() {
img.src = "./img/bear-smile.svg";
}
function render() {
if (passwordVisible) {
passInput.setAttribute("type", "text");
eye.classList.add("fa-eye");
eye.classList.remove("fa-eye-slash");
signInButton.addEventListener("click", changeImageOnClick);
} else {
passInput.setAttribute("type", "password");
eye.classList.remove("fa-eye");
eye.classList.add("fa-eye-slash");
img.src = "./img/bear-normal.svg";
}
}
// Add event listener to toggle password visibility
eye.addEventListener("click", function () {
passwordVisible = !passwordVisible;
render();
});
// Call render function initially to set initial UI state
render();