zoukankan      html  css  js  c++  java
  • 移动端支付6位密码框

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
        <script src="http://zeptojs.com/zepto.min.js"></script>
        <title>手机端六位密码输入</title>
        <style>
            *{margin: 0;padding: 0;}
            html,body{ 100%;height: 100%}
            .main{ 100%;height: 100%;background: rgba(0, 0, 0 ,0.5);position: absolute;top:0}
            .pwd-box{
                324px;
                height: 70px;
                position: relative;
                border: 1px solid #9f9fa0;
                border-radius: 3px;
                overflow:hidden;
                margin:0 auto;
                top:30%;
    
            }
            .pwd-box input[type="tel"]{
                 324px;
                height: 70px;
                color: transparent;
                position: absolute;
                top: 0;
                left: 0;
                border: none;
                font-size: 18px;
                opacity: 0;
                z-index: 1;
                letter-spacing: 35px;
            }
            .fake-box input{
                 50px;
                height: 50px;
                border: none;
                text-align: center;
                font-size: 30px;
    
            }
            .fake-box input:nth-last-child(1){
                border:none;
            }
            p{text-align: center;font-size: 20px;color: white}
        </style>
    </head>
    <body>
    <div class="main">
    <div class="pwd-box">
        <p>输入邀请码</p>
        <input type="tel" maxlength="6" class="pwd-input" id="pwd-input">
        <div class="fake-box">
            <input type="text" readonly="">
            <input type="text" readonly="">
            <input type="text" readonly="">
            <input type="text" readonly="">
            <input type="text" readonly="">
            <input type="text" readonly="">
        </div>
    </div>
    </div>
    
    
    <script>
        var $input = $(".fake-box input");
        var boxInput=$("#pwd-input");
        boxInput.focus();
        boxInput.on("input", function() {
            var pwd = $(this).val().trim();
            for (var i = 0, len = pwd.length; i < len; i++) {
                $input.eq("" + i + "").val(pwd[i]);
            }
            $input.each(function() {
                var index = $(this).index();
                if (index >= len) {
                    $(this).val("");
                }
            });
            if (len == 6) {
                //执行其他操作
            }
        });
    </script>
    </body>
    </html>
    

      

  • 相关阅读:
    html标签嵌套规则
    关于setTimeout和Promise执行顺序问题
    vue基础
    new操作符具体干了什么
    ["1", "2", "3"].map(parseInt)
    线性表
    树的一些概念和性质
    A*与IDA*
    树上启发式合并
    启发式合并
  • 原文地址:https://www.cnblogs.com/xiaobaibubai/p/6952713.html
Copyright © 2011-2022 走看看