- 정보공유
[JQUERY] 복잡한 rowspan 처리 쉽게 처리하는 방법
<table border=1>
<thead>
<tr>
<th>헤더1</th>
<th>헤더2</th>
<th>헤더3</th>
</tr>
</thead>
<tbody>
<tr>
<td class="data">1</td>
<td></td>
<td></td>
</tr>
<tr>
<td class="data">1</td>
<td></td>
<td></td>
</tr>
<tr>
<td class="data">1</td>
<td></td>
<td></td>
</tr>
<tr>
<td class="data">2</td>
<td class="data">3</td>
<td></td>
</tr>
<tr>
<td></td>
<td class="data">3</td>
<td></td>
</tr>
<tr>
<td></td>
<td class="data">3</td>
<td></td>
</tr>
</tbody>
</table>
<script type="text/javascript">
<!--
$(".data").each(function() {
var rows = $(".data:contains('" + $(this).text() + "')");
if (rows.length > 1) {
rows.eq(0).attr("rowspan", rows.length);
rows.not(":eq(0)").remove();
}
});
//-->
</script>