<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>明码</title>
</head>
<body>
<form action ='#'>
<input type="text" name="password">
<input type="button" name="showPassword" value='明码'>
</form>
<script type='text/javascript'>
var form = document.forms[0];
var password = form.password,
showPassword = form.showPassword;
showPassword.onclick = function(){
var type = password.getAttribute('type');
if (type === 'password') {
this.value = '明码';
password.setAttribute('type', 'text');
} else {
this.value = '密码';
password.setAttribute('type', 'password');
}
}
</script>
</body>
</html>
明码 与 密码 切换
最新推荐文章于 2022-12-04 17:21:09 发布