📜  如何在html代码示例中的密码输入中添加查看按钮

📅  最后修改于: 2022-03-11 14:53:21.202000             🧑  作者: Mango

代码示例2
togglePassword.addEventListener('click', function (e) {
    // toggle the type attribute
    const type = password.getAttribute('type') === 'password' ? 'text' : 'password';
    password.setAttribute('type', type);
    // toggle the eye / eye slash icon
    this.classList.toggle('bi-eye');
});Code language: JavaScript (javascript)