给单据增加(敲回车键自动跳下一个文本框的功能)

This commit is contained in:
季圣华
2020-03-14 00:07:29 +08:00
parent 66f0a30ab4
commit f461eca56c
2 changed files with 35 additions and 0 deletions

View File

@@ -429,4 +429,31 @@
*/
function myIsNaN(value) {
return typeof value === 'number' && !isNaN(value);
}
/**
* 敲回车键自动跳转到下一个文本框
* @param inputDom
*/
function autoJumpNextInput(inputDom, appendDom) {
inputDom.on("keydown","input:text:visible",function(e){
//响应回车键按下的处理
var e = event || window.event || arguments.callee.caller.arguments[0];
//捕捉是否按键为回车键可百度JS键盘事件了解更多
if(e && e.keyCode==13) {
//捕捉inputDom下的文本输入框的个数
var inputs = inputDom.find("input:text:visible");
//console.log(inputs.length);
var idx = inputs.index(this);                         // 获取当前焦点输入框所处的位置
if (idx == inputs.length - 1) {                       // 判断是否是最后一个输入框
var curKey = e.which;
if (curKey == 13) {
appendDom.click(); //新增行
}
} else {
inputs[idx + 1].focus(); // 设置焦点
inputs[idx + 1].select(); // 选中文字
}
}
});
}