<div style="display: flex;
justify-content: center;
align-content: center;
align-items: center;
background-color: aliceblue;">
<i class="far fa-eye" id="togglePassword"></i>
</div>
<script>
const togglePassword = document.querySelector('#togglePassword');
const password = document.querySelector('#pass');
togglePassword.addEventListener('click', function (e) {
const type = password.getAttribute('type') === 'password' ? 'text' : 'password';
password.setAttribute('type', type);
this.classList.toggle('fa-eye-slash');
});
</script>