标签:
function mergeTableRows(tableName,colIdx){ tableObj=document.getElementById(tableName); var lastTdText=null; var rowLen=tableObj.rows.length; for(var i=rowLen-1;i>=1;i--){ var currText=tableObj.rows[i].cells[colIdx].innerHTML; if(lastTdText==null){ sameCount=1; }else if(lastTdText!=currText){ if(sameCount>1){ tableObj.rows[i+1].cells[colIdx].rowSpan=sameCount; } sameCount=1; }else if(lastTdText==currText){ tableObj.rows[i+1].deleteCell(colIdx); sameCount++; } lastTdText=currText; } if(sameCount>1){ tableObj.rows[1].cells[colIdx].rowSpan=sameCount; } //强制表格重新绘制 var borderWidth=tableObj.border; tableObj.border=1; tableObj.border=borderWidth; }
标签:
原文地址:http://www.cnblogs.com/huanzei/p/5071416.html