본문 바로가기

프로그래밍/JavaScript

[JQuery] 리스트 셀 병합 방법

 

Spring MVC - 리스트에서 같은항목 셀 병합

 

 

 

 

 

rownum은 병합하고 싶은 열의 td index

$.fn.rowspan = function(colIdx, isStats) { 	return this.each(function(){       		var that;      		$('tr', this).each(function(row) { 			$('td:eq('+colIdx+')', this).filter(':visible').each(function(col) { 				if ($(this).html() == $(that).html() && (!isStats || isStats && $(this).prev().html() == $(that).prev().html())) { 					rowspan = $(that).attr("rowspan") || 1; 					rowspan = Number(rowspan)+1; 					$(that).attr("rowspan",rowspan); 					// do your action for the colspan cell here 					$(this).hide(); 					//$(this).remove(); 					// do your action for the old cell here 				} else { 					that = this; 				} 				// set the that if not already set 				that = (that == null) ? this : that; 			}); 		}); 	}); }; $('#row').rowspan(0);