密码显示/关闭效果
<!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>显示密码</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<form method="POST" action="" name="forms">
<span id=box><input type="password" name="password" value="" placeholder="请输入密码"></span>
<span id=click><a href="javascript:showps()">显示密码</a></span>
</form>
</body>
<script language="JavaScript">
function showps() {
if (this.forms.password.type = "password") {
document.getElementById("box").innerHTML = "<input type=\"text\" name=\"password\" value=" + this.forms.password.value + ">";
document.getElementById("click").innerHTML = "<a href=\"javascript:hideps()\">隐藏密码</a>"
}
}
function hideps() {
if (this.forms.password.type = "text") {
document.getElementById("box").innerHTML = "<input type=\"password\" name=\"password\" value=" + this.forms.password.value + ">";
document.getElementById("click").innerHTML = "<a href=\"javascript:showps()\">显示密码</a>"
}
}
</script>
</html>
浙公网安备 33010602011771号