这段代码当光标走到第三行的第一个单元格时,为什么第三个单元格也同时获取了光标,请修改代码
if (e.key === ‘ArrowLeft’) {
var tab1 = document.getElementById(‘tab1’)
var currentRow = this.parentNode
var totalCells = currentRow.cells
var totalCellsArray = Array.from(totalCells)
var insertdiv = this.children[1]
const insertinputkm = this.children[0].children[0]
const insertspanye = this.children[0].children[1]
var _self = this
const thisdivspan = this.children[1]
const insertinpud = this.children[0].children[1]
var rows = tab1.rows
var thirdRow = rows.item(2);
var lastCell = thirdRow.cells[4]
var firstCell = thirdRow.cells[1]
if(index === 0 ){
return
}
if(currentRow.previousElementSibling){
currentRow.previousElementSibling.cells[4].focus()
} else {
lastCell.previousElementSibling.focus()
}
thisdivspan.style.display = ‘block’
insertinpud.style.display = ‘none’
var nextTd = tableCells[index]
if (nextTd) {
focusNextTd2(nextTd)
if (insertinputkm.value !== ‘’) {
insertspanye.style.display = ‘block’
}
}
} }