Input type password show password

Asked

Viewed 423 times

0

I followed some tutorials to get the display input Like this one here :http://jsfiddle.net/cj3kmxL4/1/ But when I run on my pc it gives the following error: inserir a descrição da imagem aqui

Code: inserir a descrição da imagem aqui

  • Always try to post the code in text form and not in image form. This makes it easier to analyze

1 answer

0


It was only for an onloadm because the code was trying to get the value before the DOM upload

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';
                });
            }
  • 1

    Before the DOM shipment is this: document.addEventListener("DOMContentLoaded", function(){});... the onload is only fired after full page loading (images, scripts etc.)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.