Below Jquery is working fine but How could I shorten this Jquery? I have to show and hide the password for password and confirmed password? https://jsfiddle.net/c5cvLo54/1/
$(".password-showhide .show-password").click(function() {
$("#password").attr("type", "text");
$(".password-showhide .show-password").hide();
$(".password-showhide .hide-password").show();
});
$(".password-showhide .hide-password").click(function() {
$("#password").attr("type", "password");
$(".password-showhide .hide-password").hide();
$(".password-showhide .show-password").show();
});
$(".confirm-password-showhide .show-password").click(function() {
$("#confirmPassword").attr("type", "text");
$(".confirm-password-showhide .show-password").hide();
$(".confirm-password-showhide .hide-password").show();
});
$(".confirm-password-showhide .hide-password").click(function() {
$("#confirmPassword").attr("type", "password");
$(".confirm-password-showhide .hide-password").hide();
$(".confirm-password-showhide .show-password").show();
});
show/Hide password function
Here is one-of-the ways, how you can shorten your code:
This is the shortest i think you can get
I've also removed the "hide" span from each of the passwords.
you can use only one button to control.
```
html:
```
```
style:
```
```