显示隐藏密码框
作者:互联网
<head> <style> .box{ position: relative; width: 300px; border-bottom: 1px solid #ccc; margin: 100px auto; } .box input{ width: 250px; height: 28px; border:0; outline: none; } .box img{ position: absolute; width:20px; top: 8px; right:7px; } </style> </head> <body> <div class="box"> <label for=""> <img src="images/flase.png" alt="" > </label> <input type="password" name="" id=""> <script> var img =document.querySelector('img') var input =document.querySelector('input') var flag =0 // 点击一次falg进行变化才行 img.onclick =function(){ if(flag==0){ input.type=Text img.src="images/open.png" flag= 1 }else{ input.type='password' img.src='images/flase.png' flag = 0 } } </script>
标签:box,显示,img,width,密码,flag,var,input,隐藏 来源: https://www.cnblogs.com/1jiayi/p/16538786.html