仿支付宝多框输入js

仿支付宝多框输入js

监听键盘的敲击事件,一共六个input框,当第一个输入完毕,下一个框自动获取光标,继续输入..

淘建站为您提供更多_其它特效_联动效果_支付_输入,在此特别感谢您对我们的支持与厚爱!

查看演示

演示不了,点击反馈

加入收藏

下载 75 次

下载资源

14 淘币

特别说明:本站资源来自网友发布分享,仅供学习与参考,请勿用于商业用途,若有侵权请联系删除(272966172@qq.com)。

<-这里是结构代码->
 <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);

声明:本资料由淘建站会员提供,如转载注明来源,资料来源淘建站免费素材库:https://www.taojz.cn/texiao/982.html
仿支付宝多框输入js 希望对你有帮助,感谢您的支持!
  • jQuery keyboard点击弹出虚拟键盘输入text文本框...

    jQuery keyboard点击弹出虚拟键盘输入text文本框...

  • jquery keyboard制作电脑屏幕网页键盘输入功能代码

    jquery keyboard制作电脑屏幕网页键盘输入功能代码

  • jQuery微信支付宝扫二维码打赏

    jQuery微信支付宝扫二维码打赏

  • 粒子化文字(可自己输入)

    粒子化文字(可自己输入)

  • html5输入时间设置倒计时代码

    html5输入时间设置倒计时代码

  • 倒计时flash倒计时动画可输入设置的倒计时器下载

    倒计时flash倒计时动画可输入设置的倒计时器下载

  • 弹出框,6种提示框+输入框

    弹出框,6种提示框+输入框

  • jQuery结合PHP+Mysql完成自动输入

    jQuery结合PHP+Mysql完成自动输入

  • jQuery列表文字筛选输入文字筛选结果显示

    jQuery列表文字筛选输入文字筛选结果显示

  • jQuery text文本框输入火车时刻表下一个关键词查找功能

    jQuery text文本框输入火车时刻表下一个关键词查找功能

  • 原生js 表单搜索text文本框支持手写输入法

    原生js 表单搜索text文本框支持手写输入法

  • 使用Js控制输入灰色字搜索框多种搜索样式集合下载

    使用Js控制输入灰色字搜索框多种搜索样式集合下载

  • 留言(0)
    头像
     阿里云限量代金券,戳我领取
    1 2