{ if(tabObj != null) { var i,j var intSpan var strTemp for(i = 0i <tabObj.rows.lengthi++) { intSpan = 1 strTemp = tabObj.rows[i].cells[colIndex].innerText for(j = i + 1j <tabObj.rows.lengthj++) {if(strTemp == tabObj.rows[j].cells[colIndex].innerText){ intSpan++tabObj.rows[i].cells[colIndex].rowSpan = intSpantabObj.rows[j].cells[colIndex].style.display = "none" }else{ break } } i = j - 1 } }}
获取值的方式是对的用个固定的位置示例:
if (tb.rows[0].cells[0].innerHTML == tb.rows[1].cells[0].innerHTML) {
//伪代码
tb.rows[1].deleteCell(0)
tb.rows[0].cells[0].rowspan =2
}