<body>
密码:<input type="password" />
<button>眼睛</button>
</body>
<script>
let ipt = document.querySelector("input");
let btn = document.querySelector("button");
let arr = 0;
btn.onclick = function () {
// ipt.type = "text";
if (arr == 0) {
ipt.type = "text";
arr = 1;
} else {
ipt.type = "password";
arr = 0;
}
};
</script>