Password Visibility Toggle - JS 2
Tue May 18 2021 03:31:58 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.replace("fa-eye", "fa-eye-slash");
} else {
password.setAttribute("type", "password");
eyeIcon.classList.replace("fa-eye-slash", "fa-eye");
}
});
content_copyCOPY
Comments