• 点击图片显示或隐藏密码案例


    <!DOCTYPE html>
    <html lang="en">

    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <style>
            .box {
                position: relative;
                 400px;
                border-bottom: 1px solid #ccc;
                margin: 100px auto;
            }
            
            .box input {
                border: 0;
                outline: none;
                 370px;
                height: 30px;
            }
            
            .box img {
                position: absolute;
                top: 2px;
                right: 2px;
                 24px;
            }
        </style>
    </head>

    <body>
        <div class="box">
            <label for="">
                <img src="images/close.png" alt="" id="eye">
            </label>
            <input type="password" id="pwd">
        </div>


        <script>
            // 1 获取元素 
            var eye = document.getElementById('eye');
            var pwd = document.getElementById('pwd');
            // 切换显示隐藏
            var flag = 0;
            //  2 注册事件 绑定程序
            eye.onclick = function() {
                if (flag == 0) {
                    pwd.type = 'text';
                    eye.src = 'images/open.png';
                    flag = 1;
                } else {
                    pwd.type = 'password';
                    eye.src = 'images/close.png';
                    flag = 0;
                }
            }
        </script>
    </body>

    </html>
  • 相关阅读:
    SQL 列转行
    SQL 行转列
    ActionScript 3.0 学习笔记三
    VS 2010 添加扩展工具
    VS 2010 启动慢解决办法
    [SQL Server]游标示例
    SQL Server 2005 express TCP/IP 不能连接的配置
    FCKeditor.Net v2.6.3 上传图片的配置及注意事项
    HTTP/1.1 403 Forbidden
    存储过程中常使用的逻辑控制语句
  • 原文地址:https://www.cnblogs.com/ericblog1992/p/13050632.html
Copyright © 2020-2023  润新知