繁体   English   中英

是否可以以sylius的登录形式添加显示密码功能? 该脚本不起作用

[英]Is it possible to add show password functionality in login form of sylius? This script is not working

function myFunction() {
    var showpass = document.getElementsByClassName('lpass');
    if (showpass.type === "password") {
        showpass.type = "text";
    } else {
        showpass.type = "password";
    }
}

该脚本不起作用。 console.log('')它直接跳到else条件。

您的var showpass = document.getElementsByClassName('lpass'); 返回一个数组,因此使用0索引获取第一个匹配项。

var showpass = document.getElementsByClassName('lpass')[0];

您可以在这里查看有关此功能的更多信息, https://developer.mozilla.org/zh-CN/docs/Web/API/Document/getElementsByClassName

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM