回车input文本框循环获取焦点

 

input框,需要跳转的都加上 class=“input”

<input name="back_qty" id="back_qty" type="text" class="input" />

 

javascript

复制代码
<script language="javascript">
    $(function ($) {    
        var inputs = $('.input');
        inputs.eq(0).focus();
        inputs.each(function(i,e){
            $(e).keydown(function (ev){
                var ev = window.event || ev;
                if (ev.keyCode == 13) {
                    if ($(this).val() == '' || $(this).val() == null) {
                        // spans.eq(i).show();
                    } else {
                        // spans.eq(i).hide();
                        if (i < inputs.length - 1) {
                            var nextIndex = i + 1;
                            inputs.eq(nextIndex).focus();
                        }
                    }
                }  
            });
        });
    });
</script>
复制代码

 

posted @   茶叶蛋蛋  阅读(111)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示