반응형
/*
같은 값이 있는 열을 병합함
사용법 : $('#테이블 ID').rowspan(0);
/
$.fn.rowspan = function(colIdx, isStats) {
return this.each(function(){var that; $('tr', this).each(function(row) { $('td',this).eq(colIdx).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; }); });
});
};
/*
같은 값이 있는 행을 병합함
사용법 : $('#테이블 ID').colspan (0);
/
$.fn.colspan = function(rowIdx) {
return this.each(function(){var that;
$('tr', this).filter(":eq("+rowIdx+")").each(function(row) {
$(this).find('td').filter(':visible').each(function(col) {if ($(this).html() == $(that).html()) { colspan = $(that).attr("colSpan"); if (colspan == undefined) { $(that).attr("colSpan",1); colspan = $(that).attr("colSpan"); } colspan = Number(colspan)+1; $(that).attr("colSpan",colspan); $(this).hide(); // .remove(); } else { that = this; } that = (that == null) ? this : that; // set the that if not already set
});
});});
}
hy1a1a1a1a1hy11.12.12.12.1hy1
66hy18888hy110111212hy113111515hy21233hy21233hy11233hy11233hy21233hy21233
$(document).ready(function() {
/*
- 특정행을 지정할때는 rowspan(행수)
- $('#listTable ID').rowspan(0);
- /
$('table tbody tr:visible').each(function(cols) {
$('#listTable').rowspan(cols);
})
/*
- 여기까지 대체
- /
});
$(document).ready(function() {
$('table tbody tr:visible').each(function(row) {
$('#listTable').colspan(row);
})
});
반응형
'개발 하자 빵찌니 > JQuery' 카테고리의 다른 글
JQuery 비동기 Ajax 통신 데이터 주고 받기 (0) | 2021.08.22 |
---|---|
JQuery 날짜변경 이벤트 (0) | 2021.08.22 |
[jquery] jquery 로 체크박스 리스트의 체크된 값 (0) | 2018.08.25 |
jQuery row 추가 (입력창 추가), jQuery 테이블 행 추가/삭제 (0) | 2018.08.25 |
jQuery 테이블 행 추가/삭제 (0) | 2018.08.25 |