1
2<div class="signin-form u-password p-relative">
3 <span class="view-password"><i class="fas fa-eye"></i></span>
4 <input id="pass" class="pass" type="password" placeholder="Enter your password"/>
5</div>
6
7$('.view-password').on('click', function () {
8 let input = $(this).parent().find(".pass");
9 input.attr('type', input.attr('type') === 'password' ? 'text' : 'password');
10});
1 $("#showpaswd").click(function () {
2 var x = document.getElementById("cpassword");
3 if (x.type === "password") {
4 x.type = "text";
5 } else {
6 x.type = "password";
7 }
8 });
1$('#check').click(function(){
2 if(document.getElementById('check').checked) {
3 $('#test-input').get(0).type = 'text';
4 } else {
5 $('#test-input').get(0).type = 'password';
6 }
7});
8
9<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
10<input type='password' id='test-input' /> Show password <input type='checkbox' id='check' />