Password Visibility Toggle - JS 1
Tue May 18 2021 03:28:05 GMT+0000 (Coordinated Universal Time)
Saved by
@zinotrust
#javascript
const password = document.querySelector("#password");
const eyeIcon = document.querySelector("#eye");
eyeIcon.addEventListener("click", () => {
if (eyeIcon.classList.contains("fa-eye")) {
password.setAttribute("type", "text");
eyeIcon.classList.remove("fa-eye");
eyeIcon.classList.add("fa-eye-slash");
} else {
password.setAttribute("type", "password");
eyeIcon.classList.remove("fa-eye-slash");
eyeIcon.classList.add("fa-eye");
}
});
content_copyCOPY
Comments