<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 전환//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> <br><td rowspan="0">张三 </td> <br><td>男 </td> <br><td>22</td> <br><td>유학 </td> <br><td>90</td> <br></tr> <br><tr> <br><td rowspan="0">张三 </td> <br><td>여인 </td> <br><td>22</td> <br><td>语文 </td> <br><td>70</td> <br></tr> <br><tr> <br><td rowspan="0">张三 </td> <br><td>여인 </td> <br><td>22</td> <br><td>英语 </td> <br><td>60</td> <br></tr> <br><tr> <br><td rowspan="0">이사 </td> <br><td>여인 </td> <br><td>22</td> <br><td>유학 </td> <br><td>60</td> <br></tr> <br><tr> <br><td rowspan="0">이사 </td> <br><td>여인 </td> <br><td>19</td> <br><td>语文 </td> <br><td>60</td> <br></tr> <br><tr> <br><td rowspan="0">王五 </td> <br><td>男 </td> <br><td>19</td> <br><td>英语 </td> <br><td>60</td> <br></tr> <br></테이블> <br><br><script type="text/javascript"> <br>window.onload = function(){ <br>var tab = document.getElementById("tab"); <br>var col =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>function megercell(tab, col){ <br>count = 1; <br>발 = ""; <br>for(var i=0; i<tab.rows.length; i ){ <BR>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 = 개수; <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><br>function megercell1(tab, col){ <BR>count = 1; <BR>발 = ""; <BR>var rowspan = 0; <BR>for(var i=0; i<tab.rows.length;){ <BR>rowspan = parsInt(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 = 개수; <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 = 개수; <br>for(var j=from 1; j<i; j ){ <BR>tab.rows[j].cells[col].style.display = "none"; <BR>} <BR>} <BR>개수 = 1; <BR>발 = ""; <BR>} <BR>else <BR>{ <BR>i ; <BR>} <BR>} <BR>} <br><br></script> <br></body> <br></html> <br></tab.rows.length> </div>