第1个回答 2012-03-07
this.parentNode ->当前单元格(td)
int cellIndex = this.parentNode.cellIndex 取得当前cell的序号
this.parentNode.parentNode ->当前行(tr)
this.parentNode.parentNode.children[cellIndex] -> 当前的td
this.parentNode.parentNode.children[cellIndex-1] -> 当前td的左边的td(cellIndex = 0 则不存在)
this.parentNode.parentNode.children[cellIndex+1] -> 当前td的右边的td(cellIndex = this.parentNode.parentNode.children.length 则不存在)
通过 this.parentNode.parentNode.children[cellIndex-1].innerHTML = xxx 即可改变 当前td的左边的td的内容。
通过 this.parentNode.parentNode.children[cellIndex+1].innerHTML = xxx 即可改变 当前td的右边的td的内容。