js将具有连续相同内容的列进行合并

         

  function merge(tableId,col){

                var tr = document.getElementById(tableId);
                for(var i=1; i                     
                    if(tr.rows[i].cells[col].firstChild.value == tr.rows[i - 1].cells[col].firstChild.value){//col代表列
                        t = i-1;
                        while(tr.rows[i].cells[col].firstChild.value == tr.rows[t].cells[col].innerHTML){
                            tr.rows[i].cells[col].style.display="none";
                            if(tr.rows[t].cells[col].rowSpan <= (i-t)){  
                                tr.rows[t].cells[col].rowSpan +=1;      //设置前一行的rowspan+1
                            }
                            i++;
                        }
                    }               
                }
            }

你可能感兴趣的:(小算法,js)