仿支付宝多框输入js

仿支付宝多框输入js

添加时间:2021-03-09 16:17:30
站长推荐丨赞助论坛,可获取海量资源终身免费下载权限奥!
举报 举报
收藏
预览
附件 附件
  • 模板类型模板类型:联动效果
  • 模板颜色模板颜色:初级
  • 下载积分下载积分:28 米粒
  • 下载权限下载权限:

    赞助会员

监听键盘的敲击事件,一共六个input框,当第一个输入完毕,下一个框自动获取光标,继续输入..
仿支付宝多框输入js
分类:其它特效 > 联动效果 难易:初级
<-这里是结构代码->
 <div class="input">
        <input type="password" class="inpVal1" placeholder="|" maxlength="1">
        <input type="password" class="inpVal2" placeholder="|" maxlength="1">
        <input type="password" class="inpVal3" placeholder="|" maxlength="1">
        <input type="password" class="inpVal4" placeholder="|" maxlength="1">
        <input type="password" class="inpVal5" placeholder="|" maxlength="1">
        <input type="password" class="inpVal6" placeholder="|" maxlength="1">
    </div>
    <p class="showNum">单击这显示密码..</p>
.input {
            display: inline-block;
        }
        input:last-child {
             border-right: 1px solid #999;
         }
        input {
            border-top: 1px solid #999;
            border-bottom: 1px solid #999;
            border-left: 1px solid #999;
            border-right: 1px solid #999;
            width: 45px;
            height: 45px;
            outline:none;
            font-family: inherit;
            font-size: 28px;
            font-weight: inherit;
            text-align: center;
            line-height: 45px;
            color: #c2c2c2;
            background: rgba(255,255,255,0);
        }
        .showNum{
            width: 300px;
            height: 40px;
            line-height: 40px;
            text-align: center;
            border: 1px solid #cccccc;
            cursor: pointer;
        }
/*模拟支付宝的密码输入形式*/
    (function (window, document) {
        var showNum=document.getElementsByClassName(\\\'showNum\\\')[0];
        showNum.onclick=function(){
            var inpVal1=document.querySelector(\\\'.inpVal1\\\').value;
            var inpVal2=document.querySelector(\\\'.inpVal2\\\').value;
            var inpVal3=document.querySelector(\\\'.inpVal3\\\').value;
            var inpVal4=document.querySelector(\\\'.inpVal4\\\').value;
            var inpVal5=document.querySelector(\\\'.inpVal5\\\').value;
            var inpVal6=document.querySelector(\\\'.inpVal6\\\').value;
            var val=inpVal1+""+inpVal2+""+inpVal3+""+inpVal4+""+inpVal5+""+inpVal6;
            showNum.innerHTML="输入的是----"+val;
            console.log(val);
        };
        var active = 0,
                inputBtn = document.querySelectorAll(\\\'input\\\');
        for (var i = 0; i < inputBtn.length; i++) {
            inputBtn[i].addEventListener(\\\'click\\\', function () {
                inputBtn[active].focus();
            }, false);
            inputBtn[i].addEventListener(\\\'focus\\\', function () {
                this.addEventListener(\\\'keyup\\\', listenKeyUp, false);
            }, false);
            inputBtn[i].addEventListener(\\\'blur\\\', function () {
                this.removeEventListener(\\\'keyup\\\', listenKeyUp, false);
            }, false);
        }

       /*监听键盘的敲击事件*/
        function listenKeyUp() {
            if (!isNaN(this.value) && this.value.length != 0) {
                if (active < 5) {
                    active += 1;
                }
                inputBtn[active].focus();
            } else if (this.value.length == 0) {
                if (active > 0) {
                    active -= 1;
                }
                inputBtn[active].focus();
            }
        }
    })(window, document);
相关内容推荐
资源求助发帖
查看更多发帖

*

回帖描述:

*

链接类型:

*

下载链接:

密码:
发帖规则:回帖内容为会员之间的私信,普通网友无法查看。
免责声明:回帖中提供的链接内容仅供会员之间学习参考使用,获取内容后请在法律法规范围内使用。回帖提供的内容应符合法律法规要求,不得违反法律法律的要求。
站点权责:回帖内容如违反法律法规,站点有权封停账号使用权利。对用户举报的内容,站点有责任及时删除违规内容。
热点内容推荐
标题:仿支付宝多框输入js

*

描述:
平均回复时间:3-10分钟
规则介绍:悬赏寻求论坛网友分享资源,站点对分享内容的准确性,合法性,版权等没有足够的监管能力。如果您发现资源不正确,无法使用,不符合法律法律等情况,您可以直接举报资源。站长将尽快核实您的举报,并根据情况,采取封号,退换米粒等处理。

*

回帖描述:

*

链接类型:

*

阅读权限:

*

下载链接:

密码:
发帖规则:回帖内容为会员之间的私信,普通网友无法查看。
免责声明:回帖中提供的链接内容仅供会员之间学习参考使用,获取内容后请在法律法规范围内使用。回帖提供的内容应符合法律法规要求,不得违反法律法律的要求。
站点权责:回帖内容如违反法律法规,站点有权封停账号使用权利。对用户举报的内容,站点有责任及时删除违规内容。
  • 背景波浪
  • 背景波浪
  • 波浪
  • 波浪
客服
在线咨询
周一 至 周日 9:00 ~ 22:00
QQ:1326974360
微信:juyoubuluo6688
客服热线
18205485173
工作日 9:00 ~ 18:00
微信扫码咨询
客户服务
欢迎咨询服务
咨询量较多时,请耐心等待
社群

关注公众号

获取更多资讯

扫码进群(QQ)

与更多大牛交流沟通

0.091632s