1togglePassword.addEventListener('click', function (e) {
2 // toggle the type attribute
3 const type = password.getAttribute('type') === 'password' ? 'text' : 'password';
4 password.setAttribute('type', type);
5 // toggle the eye / eye slash icon
6 this.classList.toggle('bi-eye');
7});Code language: JavaScript (javascript)