• JavaScript 表格指定列,根据相同值跨行


    function mergeTableRows(tableName,colIdx){
    
        tableObj=document.getElementById(tableName);
        var lastTdText=null;
        var rowLen=tableObj.rows.length;
        for(var i=rowLen-1;i>=1;i--){
            var currText=tableObj.rows[i].cells[colIdx].innerHTML;
            if(lastTdText==null){
                sameCount=1;
            }else if(lastTdText!=currText){
                if(sameCount>1){
                    tableObj.rows[i+1].cells[colIdx].rowSpan=sameCount;
                }
    
                sameCount=1;
            }else if(lastTdText==currText){
                tableObj.rows[i+1].deleteCell(colIdx);
                sameCount++;
            }
    
            lastTdText=currText;
        }
    
        if(sameCount>1){
            tableObj.rows[1].cells[colIdx].rowSpan=sameCount;
        }
    
        //强制表格重新绘制
        var borderWidth=tableObj.border;
        tableObj.border=1;
        tableObj.border=borderWidth;
    }
  • 相关阅读:
    CPU使用率终极计算
    elementui
    spring security oauth2
    maven bom
    vue jsx
    [spring cloud] feign声明
    加分项
    JAVA日报
    JAVA日报
    JAVA日报
  • 原文地址:https://www.cnblogs.com/huanzei/p/5071416.html
Copyright © 2020-2023  润新知