I'm making password hide/show toggle with jQuery, when I add two buttons one for show and the other one for hide everything works perfectly but i want to toggle here's the code
jQuery
$(document).ready(function(){
$('.1').on('click',function(){
var pass = $('.password');
if(pass.attr('type','password')){
pass.attr('type','text');
}
else{
pass.attr('type','password');
}
})
})
HTML
<div id="main">
<h1>Form</h1>
Enter your login <input class="login">
Enter password here <input class="password" type="password">
<button class="1">Show password</button>
</div>