Hi,
I need to create a button which shows and hide the password inside an input field.
I wrote this code which works partially:
- $('.show-hide-password').click(function(e) {
- $(this).text(($(this).text() === 'Hide' ? 'Show' : 'Hide')); // Change the text
- $('.engage-password__field').attr('type', 'text');
- e.preventDefault();
- });
If I click on "Show" button it shows the password. But it should hide the password by second click. So I need something to toggle the attribute each time I click the button.
How can I do this?
Thanks