< html >
<head>
<meta charset="UTF-8">
<title></title>
</head>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<body onload="autoRowSpan1(tb,1,1)">
<table id="tb" border="1">
<thead>
<tr>
<td align="center"></td>
<td></td>
<td></td>
</tr>
</thead>
<tr>
<td align="center">1</td>
<td></td>
<td></td>
</tr>
<tr>
<td align="center">3</td>
<td></td>
<td></td>
</tr>
<tr>
<td align="center">4</td>
<td></td>
<td></td>
</tr>
<tr>
<td align="center">5</td>
<td></td>
<td></td>
</tr>
<tr>
<td align="center">6</td>
<td></td>
<td></td>
</tr>
<tr>
<td align="center">2</td>
<td></td>
<td></td>
</tr>
</table>
<script>
function autoRowSpan1(tb,row,col) {
var lastValue="";
var value="";
var pos=1;
var increase = 0;
for(var i=row;i<tb.rows.length;iPP){
value = tb.rows[i].cells[col].innerText;
if(lastValue == value){
tb.rows[i].deleteCell(col);
tb.rows[i-pos].cells[col].rowSpan = tb.rows[i-pos].cells[col].rowSpan+1;
//
tb.rows[i].deleteCell(col-1);
tb.rows[i-pos].cells[col-1].rowSpan = tb.rows[i-pos].cells[col-1].rowSpan+1;
posPP;
}else{
lastValue = value;
pos=1;
//
if(i==1){
tb.rows[1].cells[0].innerText=1;
}else{
increasePP;
tb.rows[i].cells[col-1].innerText= parseInt(tb.rows[1].cells[0].innerText)+parseInt(increase);
}
}
}
}
</script>
</body>
< / html >
expectation: there is only one China in the second column; China includes Henan, Beijing and Sichuan