标签:
<span style="font-family:Microsoft YaHei;font-size:14px;">//合并单元格 function cellHandler(){ var tab = document.getElementById("data_table"); //maxCol循环列 var maxCol = 2, val, count, start; for(var col = maxCol-1; col >= 0 ; col--){ count = 1; val = ""; for(var i=0; i<tab.rows.length; i++){ if(val == tab.rows[i].cells[col].innerHTML){ count++; }else{ if(count > 1){ //合并 start = i - count; tab.rows[start].cells[col].rowSpan = count; for(var j=start+1; j<i; j++){ tab.rows[j].cells[col].style.display = "none"; } count = 1; } val = tab.rows[i].cells[col].innerHTML; } } if(count > 1 ){ //合并,最后几行相同的情况下 start = i - count; tab.rows[start].cells[col].rowSpan = count; for(var j=start+1; j<i; j++){ tab.rows[j].cells[col].style.display = "none"; } } } };</span>
标签:
原文地址:http://blog.csdn.net/ring_to_ping/article/details/47081953