<!DOCTYPE HTML>
<html>
<head>
<title>Example</title>
<meta charset=
"utf-8"
/>
<style></style>
<script src=
"js/jquery-2.1.4.min.js"
></script>
</head>
<body>
<table id=
"process"
cellpadding=
"2"
cellspacing=
"0"
border=
"1"
>
<thead>
<tr >
<td>col0</td>
<td>col1</td>
<td>col2</td>
<td>col3</td>
</tr>
</thead>
<tbody>
<tr>
<td>SuZhou</td>
<td>11111</td>
<td>22222</td>
<td>SuZhouCity</td>
</tr>
<tr>
<td>SuZhou</td>
<td>33333</td>
<td>44444</td>
<td>SuZhouCity</td>
</tr>
<tr>
<td>SuZhou</td>
<td>55555</td>
<td>66666</td>
<td>SuZhouCity</td>
</tr>
<tr>
<td>ShangHai</td>
<td>77777</td>
<td>88888</td>
<td>ShangHaiCity</td>
</tr>
<tr>
<td>ShangHai</td>
<td>uuuuu</td>
<td>hhhhh</td>
<td>ShangHaiCity</td>
</tr>
<tr>
<td>ShangHai</td>
<td>ggggg</td>
<td>ccccc</td>
<td>ShangHaiCity</td>
</tr>
<tr>
<td>GuangZhou</td>
<td>ttttt</td>
<td>eeeee</td>
<td>GuangZhouCity</td>
</tr>
<tr>
<td>GuangZhou</td>
<td>ppppp</td>
<td>qqqqq</td>
<td>GuangZhouCity</td>
</tr>
</tbody>
</table>
<script type=
"text/javascript"
>
function
_w_table_rowspan(_w_table_id,_w_table_colnum){
_w_table_firsttd =
""
;
_w_table_currenttd =
""
;
_w_table_SpanNum = 0;
_w_table_Obj = $(_w_table_id +
" tr td:nth-child("
+ _w_table_colnum +
")"
);
_w_table_Obj.each(
function
(i){
if
(i==0){
_w_table_firsttd = $(
this
);
_w_table_SpanNum = 1;
}
else
{
_w_table_currenttd = $(
this
);
if
(_w_table_firsttd.text()==_w_table_currenttd.text()){
_w_table_SpanNum++;
_w_table_currenttd.hide();
_w_table_firsttd.attr(
"rowSpan"
,_w_table_SpanNum);
}
else
{
_w_table_firsttd = $(
this
);
_w_table_SpanNum = 1;
}
}
});
}
function
_w_table_colspan(_w_table_id,_w_table_rownum,_w_table_maxcolnum){
if
(_w_table_maxcolnum == void 0){_w_table_maxcolnum=0;}
_w_table_firsttd =
""
;
_w_table_currenttd =
""
;
_w_table_SpanNum = 0;
$(_w_table_id +
" tr:nth-child("
+ _w_table_rownum +
")"
).each(
function
(i){
_w_table_Obj = $(
this
).children();
_w_table_Obj.each(
function
(i){
if
(i==0){
_w_table_firsttd = $(
this
);
_w_table_SpanNum = 1;
}
else
if
((_w_table_maxcolnum>0)&&(i>_w_table_maxcolnum)){
return
""
;
}
else
{
_w_table_currenttd = $(
this
);
if
(_w_table_firsttd.text()==_w_table_currenttd.text()){
_w_table_SpanNum++;
_w_table_currenttd.hide();
_w_table_firsttd.attr(
"colSpan"
,_w_table_SpanNum);
}
else
{
_w_table_firsttd = $(
this
);
_w_table_SpanNum = 1;
}
}
});
});
}
$(document).ready(
function
(){
_w_table_rowspan(
"#process"
,1);
});
</script>
</body>
</html>