<style>
.box{
position: relative;
width: 400px;
border-bottom: 2px solid #ccc;
margin: 100px auto;
}
.box input{
width: 370px;
height: 30px;
border: 0;
outline: none;
}
.box img{
position: absolute;
top: 2px;
right: 2px;
width: 24px;
}
</style>
<!-- JS密码输入 -->
<div class="box">
<label for="">
<img src="闭眼.jpg" id="eye"/>
</label>
<input type="password" name="" id="pwd"/>
</div>
<script>
var img = document.getElementById('eye');
var input = document.getElementById('pwd');
var flag = 0;
img.onclick = function(){
if(flag == 0){
input.type = 'text';
img.src = '睁眼.jpg';
flag = 1;
}else{
input.type = 'password';
img.src = '闭眼.jpg';
flag = 0;
}
}
</script>
【JS】JS密码输入
最新推荐文章于 2023-11-27 16:06:10 发布