html中table格式處理

for (var i=0;i<tbsub.rows.length;i++){
   
if(i==tbsub.rows.length-1){
     
break;
   }
   
if(tbsub.rows(i+1).mid==tbsub.rows(i).mid){
     
var nodes=xmldoc.selectNodes("//z:row[@mid='"+tbsub.rows(i).mid+"']")
     tbsub.rows(i).cells(
0).rowSpan=nodes.length
     tbsub.rows(i).cells(
1).rowSpan=nodes.length
     
for(var j=1;j<nodes.length;j++){
       tbsub.rows(j
+i).cells(0).style.display="none"
       tbsub.rows(j
+i).cells(1).style.display="none"
    }
    i
=i+nodes.length
  }
 }
上面代碼中tbsub是table表單的id,該表單已經通過xml和xsl解析的方式生成,xml數據就在xmldoc中.已經生成的table經過上面的程序的處理,將會合併某幾列數據相同的行,其結果如下:
原文地址:https://www.cnblogs.com/oisiv/p/112964.html