how to make password textbox value visible when hover an icon

前端 未结 11 1080
误落风尘
误落风尘 2021-01-31 03:01

Good day all,

I have a form that has a password field:


Naturally, the i

11条回答
  •  清歌不尽
    2021-01-31 03:51

    1 minute googling gave me this result. See the DEMO!

    HTML

    jQuery

    // ----- Setup: Add dummy text field for password and add toggle link to form; "offPage" class moves element off-screen
    $('input[type=password]').each(function () {
        var el = $(this),
            elPH = el.attr("placeholder");
        el.addClass("offPage").after('');
    });
    $('form').append('Toggle Password Visibility');
    
    // ----- keep password field and dummy text field in sync
    $('input[type=password]').keyup(function () {
        var elText = $(this).val();
        $('.passText').val(elText);
    });
    $('.passText').keyup(function () {
        var elText = $(this).val();
        $('input[type=password]').val(elText);
    });
    
    // ----- Toggle link functionality - turn on/off "offPage" class on fields
    $('a.togglePassText').click(function (e) {
        $('input[type=password], .passText').toggleClass("offPage");
        e.preventDefault(); // <-- prevent any default actions
    });
    

    CSS

    .offPage {
        position: absolute;
        bottom: 100%;
        right: 100%;
    }
    

提交回复
热议问题