首页 > 编程 > JavaScript > 正文

jquery 合并内容相同的单元格(示例代码)

2019-11-20 21:28:28
字体:
来源:转载
供稿:网友
如下所示:
复制代码 代码如下:

 function _w_table_rowspan(_w_table_id,_w_table_colnum){
        _w_table_firsttd = "";
        _w_table_currenttd = "";
        _w_table_SpanNum = 0;
        _w_table_Obj = $(_w_table_id + " tr td:nth-child(" + _w_table_colnum + ")");
        _w_table_Obj.each(function(i){
            if(i==0){
                _w_table_firsttd = $(this);
                _w_table_SpanNum = 1;
            }else{
                _w_table_currenttd = $(this);
                if(_w_table_firsttd.text()==_w_table_currenttd.text()){
                    _w_table_SpanNum++;
                    _w_table_currenttd.hide(); //remove();
                    _w_table_firsttd.attr("rowSpan",_w_table_SpanNum);
                }else{
                    _w_table_firsttd = $(this);
                    _w_table_SpanNum = 1;
                }
            }
        });
    }   

    $(function(){   
    _w_table_rowspan("#_gvInformation",1);
    })
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表