js获取所有的input框元素 给某个input框家焦点事件

@keyup.native="tdItem.onKeyUp($event, trItem, trIndex)"
               ( item , row , index)   
 
// 获取所有input
let inputAll = document.querySelectorAll('.table_input input');
// 向上键盘 =38
if ( item.keyCode === 38) {
newIndex -= 1;
if (inputAll[newIndex]) {
inputAll[newIndex].focus();
}
}
// 向下键盘 =40
if ( item.keyCode === 40) {
newIndex += 1;
if (inputAll[newIndex]) {
inputAll[newIndex].focus();
}
}

猜你喜欢

转载自www.cnblogs.com/wssdx/p/11122179.html