<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="jquery-1.8.3.js"></script>
<script type="text/javascript">
$(function () {
$('#ipId').click(function () {
var tdArr = $('.cls');
var oldObj = tdArr[0];
var rowspan = 1;
for (var i = 1; i < tdArr.length; i++) {
var newObj = tdArr[i];
if ($(oldObj).html() == $(newObj).html()) {
rowspan++;
$(newObj).remove();
$(oldObj).attr("rowspan", rowspan);
}
else {
$(oldObj).attr("rowspan", rowspan);
rowspan = 1;
oldObj = newObj;
}
}
});
});
</script>
</head>
<body>
<input type="button" value="button" id="ipId" />
<table border="1" id="grouptable">
<tbody>
<tr>
<td class="cls">A</td>
<td>AA</td>
<td>AAA</td>
</tr>
<tr>
<td class="cls">A</td>
<td>BB</td>
<td>BBB</td>
</tr>
<tr>
<td class="cls">A</td>
<td>CC</td>
<td>CCC</td>
</tr>
<tr>
<td class="cls">A</td>
<td>DD</td>
<td>DDD</td>
</tr>
<tr>
<td class="cls">B</td>
<td>CC</td>
<td>CCC</td>
</tr>
<tr>
<td class="cls">B</td>
<td>DD</td>
<td>DDD</td>
</tr>
</tbody>
</table>
</body>
</html>