/**
* 封装的一个JQuery小插件
* @param {Object} colNo
* @memberOf {TypeName}
* @return {TypeName}
*/
jQuery.fn.rowspan = function(colNo) {
return this.each(function(){
var that;
$('tr', this).each(function(row){
$('td:eq('+ colNo +')', this).filter(':visible').each(function(col){
if (that != null && $(this).html() == $(that).html()) {
rowspan = $(that).attr("rowSpan");
if (rowspan == undefined) {
$(that).attr("rowSpan", 1);
rowspan = $(that).attr("rowSpan");
}
rowspan = Number(rowspan) + 1;
$(that).attr("rowSpan", rowspan);
$(this).hide();
} else {
that = this;
}
});
});
});
};
* 封装的一个JQuery小插件
* @param {Object} colNo
* @memberOf {TypeName}
* @return {TypeName}
*/
jQuery.fn.rowspan = function(colNo) {
return this.each(function(){
var that;
$('tr', this).each(function(row){
$('td:eq('+ colNo +')', this).filter(':visible').each(function(col){
if (that != null && $(this).html() == $(that).html()) {
rowspan = $(that).attr("rowSpan");
if (rowspan == undefined) {
$(that).attr("rowSpan", 1);
rowspan = $(that).attr("rowSpan");
}
rowspan = Number(rowspan) + 1;
$(that).attr("rowSpan", rowspan);
$(this).hide();
} else {
that = this;
}
});
});
});
};
本文介绍了一个基于jQuery的小插件,该插件能够实现表格中相同内容单元格的合并,通过设置参数colNo来指定需要进行合并的列号。此插件适用于需要简化表格显示或减少重复数据展示的场景。
2158

被折叠的 条评论
为什么被折叠?



