合并单元格
<script type="text/javascript">
$(function(){
//trackTable为表格的id
for(var col=0;col<trackTable.rows[1].cells.length;col++){
$("#trackTable").rowspan(col);
}
})
//封装的一个JQuery小插件
jQuery.fn.rowspan = function(colIdx) {
return this.each(function(){
var that;
$('tr', this).each(function(row) {
$('td:eq('+colIdx+')', this).filter(':visible').each(function(col) {
if (that!=null && $(this).html() == $(that).html() && $(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;
}
});
});
});
}
</script>
注:本篇跟其他帖子有雷同的地方,我只是借用并修改,望原作者理解