Input type password show password [duplicate]

0

I followed some tutorials to get the viewer in the input Like this one here: link However when I run on my pc it gives the following error:

Code:

    
asked by anonymous 13.12.2018 / 03:00

1 answer

0

It was just for an onloadm because the code was trying to get the value before loading the DOM

window.onload=function(){
 var input = document.querySelector('#input input');
                var img = document.querySelector('#input img');
                var visivel = false;
                img.addEventListener('mousedown', function () {
                visivel = true;
                input.type = 'text';
                });
                window.addEventListener('mouseup', function (e) {
                if (visivel) visivel = !visivel;
                input.type = 'password';
                });
            }
    
13.12.2018 / 03:05