输入完一个后按下回车键光标自动移动到下一个表单
发布时间
阅读量:
阅读量
.enterfocus = function (selector, callbackFunc) { // 按住 enter 键自动切换到下一行的 input
let inputBoxes = document.querySelectorAll(selector);
for (let i of inputBoxes) {
inputBox = i;
inputBox.addEventListener('keyup', function (event) {
if (event.keyCode === 13) { // 按了 enter 键
if (i === inputBoxes.slice().last) {
if (callbackFunc && callbackFunc()) return;
} else {
let nextInputBox = inputBoxes[i + 1];
.focus(nextInputBox);
}
}, false);
}
}
};
使用:
.activate焦点(#form1 input, function () { .initiate触发(.dbyt("btn_ok"), "触发电性事件"); // 点击触发动作(触发电性事件), tap focusing selec
全部评论 (0)
还没有任何评论哟~
