<div class="codetitle"> <span><a style="CURSOR: pointer" data="42203" class="copybut" id="copybut42203" onclick="doCopy('code42203')"><u>复制代</u></a></span> 代码如下:</div> <div class="codebody" id="code42203"> <br><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <BR><html xmlns="http://www.w3.org/1999/xhtml"> <br> <br><meta http-equiv="Content-Type" content="text/html; charset=gbk" /> <br><title>無标题文档 </title> <br></head> <br><br> <br><table width="100%" border="1" cellpacing="0" cellpadding="0" id="tab"> <br><tr> <br><td rowspan="0">张三 </td> <br><td>男</td> <br><td>22 </td> <br><td>数学 </td> <br><td>90 </td> <br></tr> <br> </tr> <tr> <br><td rowspan="0">张三 </td> <br><td>男</td> <br><td>22 </td> <br><td>数学 </td> <br><td>90 </td> <br></tr> <br> </tr> <tr> <br><td rowspan="0">张三 </td> <br><td>女</td> <br><td>22 </td> <br><td>语文</td> <br><td>70 </td> <br></tr> <br> </tr> <tr> <br><td rowspan="0">张三 </td> <br><td>女</td> <br><td>22 </td> <br><td>英語 </td> <br> </td> <td>60 </td> <br></tr> <br> </tr> <tr> <br><td rowspan="0">李四 </td> <br><td>女</td> <br><td>22 </td> <br><td>数学 </td> <br><td>60 </td> <br></tr> <br> </tr> <tr> <br><td rowspan="0">李四 </td> <br><td>女</td> <br><td>19 </td> <br><td>语文</td> <br><td>60 </td> <br></tr> <br> </tr> <tr> <br><td rowspan="0">王五 </td> <br><td>男</td> <br><td>19 </td> <br><td>英語 </td> <br> </td> <td>60 </td> <br></tr> <br></table> <br><br><script type="text/javascript"> <br>window.onload = function(){ <br>var tab = document.getElementById("tab"); <br>varcol=0; <br><br>megercell(タブ, 列); <br><br>megercell1(タブ、列 1); <br><br>for(var i=0; i<tab.rows.length i>//alert(tab.rows[i].cells[0].getAttribute("rowspan")) ; <br>} <br>}; <br><br><br>関数 megercell(tab,col){ <br>カウント = 1; <br>val = ""; <br>for(var i=0; i<tab.rows.length i>if(val == tab.rows[i].cells[col].innerHTML){ <br>count ; <br>}else{ <br>if(count > 1){ <br>from = i - count; <br><br>tab.rows[from].cells[col].rowSpan = count; <br>for(var j=from 1; j<i j>tab.rows[j].cells[col].style.display = "none"; <br>} <br>カウント = 1; <br>} <br>val = tab.rows[i].cells[col].innerHTML; <br>} <br>} <br>} <br><br>function megercell1(tab,col){ <br>count = 1; <br>val = ""; <br>var 行スパン = 0; <br>for(var i=0; i<tab.rows.length>rowspan = parseInt(tab.rows[i].cells[0].getAttribute("rowspan")); <br><br>if(rowspan) <br>{ <br>for(var n = 0; n < rowspan; n ) <BR>{ <BR>if(val == tab.rows[i].セル[col].innerHTML){ <BR>カウント ; <BR>}else{ <BR>if(count > 1){ <BR>from = i - count; <BR>tab.rows[from].cells[col].rowSpan = count; <BR>for(var j=from 1; j<i; j ){ <BR>tab.rows[j].cells[col].style.display = "none"; <BR>} <BR>カウント = 1; <BR>} <BR>val = tab.rows[i].cells[col].innerHTML; <BR>} <BR>私; <BR>} <BR>if(count > 1) <BR>{ <BR>from = i - count; <br><br>alert(「 " i " " カウントから); <BR>tab.rows[from].cells[col].rowSpan = count; <BR>for(var j=from 1; j<i; j ){ <BR>tab.rows[j].cells[col].style.display = "none"; <BR>} <BR>} <BR>カウント = 1; <BR>val = ""; <BR>} <BR>else <BR>{ <BR>i ; <BR>} <BR>} <BR>} <br><br></script> <br></body> <br></html> <br></tab.rows.length></i></tab.rows.length></tab.rows.length> </tr> </div>