<!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>
<style>
.box{
position:relative;
width:400px;
border:1px solid #ccc;
margin:100 px auto;
}
.box input{
width: 300px;
height:30px;
border:0;
outline:none;
}
.box img{
position:absolute;
top:10px;
right:10px;
width:20px;
}
</style>
<body>
<div class="box">
<label for="">
<img src="images\pexels-victor-dunn-11389732.jpg" alt="" id ="eye">
<img src="" alt="" id ="eye">
</label>
<input type="password" name ="" id="pwd">
</div>
<script>
var eye =document.getElementById('eye');
var pwd =document.getElementById('pwd');
var flag = 0;
eye.onclick = function(){
if(flag == 0){
pwd.type ='text';
eye.src= "images\pexels-kelly-9227744.jpg";
flag = 1;
}else {
pwd.type ='password';
eye.src = "images\pexels-victor-dunn-11389732.jpg";
flag = 0;
}
}
</script>
</body>
</html>