ITPub博客

首页 > IT职业 > IT职场 > 多个文本框录入,使用回车键替找Tab键

多个文本框录入,使用回车键替找Tab键

IT职场 作者:cylong 时间:2021-09-09 09:46:18 0 删除 编辑

为了快速把form的所有文框输入完毕,我们不必使用鼠标去focus文本框。

在html页中放几个文本框:
图片描述

 

    
            
    
            
    
            
    
            
    
            
    
            

Source Code

 

有几点需要注意和了解。
网页加载时,focus第一个文本框,
还要监控回车值:
图片描述

 

 var $txtInput = $('input:text');        $txtInput.first().focus();        $txtInput.bind('keydown', function (e) {            if (e.which == 13) {                e.preventDefault();                var nxtIdx = $txtInput.index(this) + 1;                              $txtInput.filter(":eq(" + nxtIdx + ")").focus();            }        });

Souce Code

 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2005/viewspace-2811996/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-04-16

  • 博文量
    106
  • 访问量
    1359