//合并行单元格
$.fn.rowspan=function(options){
if(!(this[0].tagName=='TABLE')){
throw new Error("选择器必须是table");
}
var defaults = {'td':1} ;
var options = $.extend(defaults, options);
this.each(function () {
var tds=$(this).find("tbody td:nth-child("+options.td+")");
var current_td=tds.eq(0);
var k=1;
tds.each(function(index, element) {
if($(this).text()==current_td.text()&&index!=0){
k++;
$(this).remove();
current_td.attr("rowspan",k); //跨行合并
current_td.css("vertical-align","middle");
}else{
current_td=$(this);
k=1;
}
});
});
} ;
$.fn.rowspan=function(options){
if(!(this[0].tagName=='TABLE')){
throw new Error("选择器必须是table");
}
var defaults = {'td':1} ;
var options = $.extend(defaults, options);
this.each(function () {
var tds=$(this).find("tbody td:nth-child("+options.td+")");
var current_td=tds.eq(0);
var k=1;
tds.each(function(index, element) {
if($(this).text()==current_td.text()&&index!=0){
k++;
$(this).remove();
current_td.attr("rowspan",k); //跨行合并
current_td.css("vertical-align","middle");
}else{
current_td=$(this);
k=1;
}
});
});
} ;
例子
projectDataActivity.rebackClick = function(event){
var table = $(‘table','#beforelistgrid');
table.rowspan({td:1});
};