仿京东显示隐藏密码明文案例

 

 

  <body>
    密码:<input type="password" />
    <button>眼睛</button>
  </body>
  <script>
    let ipt = document.querySelector("input");
    let btn = document.querySelector("button");
    let arr = 0;
    btn.onclick = function () {
      // ipt.type = "text";
      if (arr == 0) {
        ipt.type = "text";
        arr = 1;
      } else {
        ipt.type = "password";
        arr = 0;
      }
    };
  </script>

 

posted @ 2022-04-18 11:11  罗砂  阅读(99)  评论(0)    收藏  举报