求大神帮忙,table表格用插件sortElements排序,但是table有一列是用了rowspan,合并了几行,然后排序就乱了,不知道该怎么办 ,代码如下:
<table id="requests" style="border-collapse: collapse;font-size: 14px;line-height: 115%;text-align:right;max-width: 100%;table-layout: fixed;border-spacing:0" border="1" >
<tr>
<th class="th_color">域名</th>
<th class="th_color">日期</th>
<th class="th_color" id="all_num">询盘总数<span class="glyphicon glyphicon-resize-vertical"></th>
<th class="th_color" id="todb_num">入库操作总数<span class="glyphicon glyphicon-resize-vertical"></th>
<th class="th_color" id="normal_num">实际入库总数<span class="glyphicon glyphicon-resize-vertical"></th>
<th class="th_color" id="1_num">过滤邮件数<span class="glyphicon glyphicon-resize-vertical"></th>
<th class="th_color" id="2_num">格式错误邮件数<span class="glyphicon glyphicon-resize-vertical"></th>
<th class="th_color" id="3_num">缺失地址邮件数<span class="glyphicon glyphicon-resize-vertical"></span></th>
<th class="th_color" id="4_num">ip过滤数<span class="glyphicon glyphicon-resize-vertical"></span></th>
<th class="th_color" id="percent">入库统计%<span class="glyphicon glyphicon-resize-vertical"></span></th>
<th class="th_color"></th>
</tr>
<?
$weeks=array('日','一','二','三','四','五','六');
?>
<?foreach($reg->web_reqs as $key => $web_reqs){?>
<?$domain=str_replace(".","_",$key); ?>
<tr>
<td class="td1" id="domain_<?=$domain?>" rowspan="<?=count($web_reqs)?>"><?=$key?></td>
<!-- </tr>-->
<!-- --><?//$num=0;?>
<!-- <tr>-->
<?foreach($web_reqs as $date => $web_req){?>
<!-- --><?//if($num!=0){?>
<!-- <tr>-->
<!-- --><?//}?>
<?$week=$weeks[date('w', strtotime($date))];?>
<td class="td1"><a href="javascript:void(0);" onclick='get_spiders("<?=$key?>","<?=$date?>",<?=$web_req['all_requests']?>)'><?=$date?></a>(<?=$week?>)</td>
<td class="td1"><?=$web_req['all_requests']?></td>
<td class="td1"><?=$web_req['todb_requests']?></td>
<td class="td1"><?=$web_req['normal_requests']?></td>
<td class="td1"><?=$web_req['all_status1_nums']?></td>
<td class="td1"><?=$web_req['all_status2_nums']?></td>
<td class="td1"><?=$web_req['all_status3_nums']?></td>
<td class="td1"><?=$web_req['all_status4_nums']?></td>
<td class="td1"><?=sprintf("%.2f",($web_req['normal_requests']/$web_req['all_requests'])*100)?>%</td>
<?if(empty($reg->domain)){?>
<td class="td1">
<a href="/index.php?r=adminStatistic/inquiry&starttime=<?=date("Y-m-d",strtotime('-7 days',strtotime($reg->to)));?>&endtime=<?=$reg->to?>&domain=<?=$key?>&subm=查询"><button id="go" onclick="go()" type="button">详细</button> </a>
</td>
<?}else{?>
<td style="width: 120px;">
<a href="/index.php?r=adminStatistic/inquiry"><button id="back" onclick="back()" type="button">返回</button> </a>
</td>
<?}?>
</tr>
<?$num++;}?>
<?}?>
</table>
<script>
var table = $('#requests');
$('#all_num,#todb_num,#normal_num,#1_num,#2_num,#3_num,#4_num,#percent')
.each(function(){
var th = $(this),
thIndex = th.index(),
inverse = false;
th.click(function(){
table.find('td.td1').filter(function(){
return $(this).index() === thIndex;
}).sortElements(function(a, b){
return parseFloat($.text([a])) > parseFloat($.text([b])) ?
inverse ? -1 : 1
: inverse ? 1 : -1;
}, function(){
return this.parentNode;
});
inverse = !inverse;
});
});
$(function(){
$("input[name='starttime']").prop("disabled","");
$("input[name='endtime']").prop("disabled","");
}
);
</script>