[英]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.