<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<input type="password" id="password">
<button id="eyebtn">eye</button>
<script>
var passInput = document.getElementById("password")
var eyeBtn = document.querySelector("#eyebtn")
eyeBtn.onclick = function(){
console.log(passInput.type)
if(passInput.type==="password"){
passInput.type = "text"
}else{
passInput.type = "password"
}
}
</script>
</body>
</html>
密码可视化小案例
于 2023-03-29 17:51:54 首次发布