给文本框增加回车跳转下一个的事件

This commit is contained in:
季圣华
2021-10-29 00:27:11 +08:00
parent deead4b32b
commit 8f30705c79
17 changed files with 216 additions and 159 deletions

View File

@@ -684,4 +684,29 @@ export function handleIntroJs(module, cur_version) {
//点击结束按钮后, 执行的事件
Vue.ls.set('intro_cache_' + module, cur_version, 100 * 24 * 60 * 60 * 1000);
}).start()
}
/**
* 回车后自动跳到下一个input
*/
export function autoJumpNextInput(domInfo) {
let domIndex = 0
let inputs = document.getElementById(domInfo).getElementsByTagName('input')
inputs[domIndex].focus()
document.getElementById(domInfo).addEventListener('keydown',function(e){
if(e.keyCode === 13){
domIndex++
if(domIndex === inputs.length) {
domIndex = 0
}
inputs[domIndex].focus()
}
})
for(let i=0; i<inputs.length; i++){
//这个index就是做个介质来获取当前的i是第几个
inputs[i].index = i;
inputs[i].onclick = function () {
domIndex = this.index
}
}
}