F. Flores F. Flores - 5 months ago 13
Javascript Question

How to remove and add input type with jQuery

Hello Im trying to create a login, everything its ok but in my password input I want a span that when user click on it show the password and when click again hide the password at the moment I only have the first step (show the password).

Here is the code

Answer

You should try with this:

$('#xd').on('mouseup', function () {
    $('#ContraseƱa').attr('type', 'password')
});

$('#xd').on('mousedown', function () {
    $('#ContraseƱa').attr('type', 'text')
});

Code here