我正在使用 jQuery 表格排序器插件,我想通过在千位上使用逗号分隔符来使我的表格更具可读性,即 number_format($value, 0, " ", ",");
但是,这会破坏排序。我一直在寻找解决方案(例如http://lab.christianmontoya.com/jquery-tablesort-numbers-commas/),但我没有设法调整它并适应我的桌子。我是脚本新手,所以请放纵一下。
我的 javascript 块应该是什么样的?
<head>
<script type="text/javascript">
$(document).ready(function() {
$("#myTable").tablesorter( {
sortList: [[1,1], [2,1]],
widgets: ['zebra'],
} );
});
</script>
</head>
<body>
<table id="myTable" class="tablesorter">
<thead>
<tr>
<th>Username</th>
<th>Level</th>
<th>Experience</th>
</tr>
</thead>
<tbody>
<tr>
<td>Fiery</td>
<td><?php echo number_format(2400, 0, " ", ","); ?></td>
<td><?php echo number_format(378433689, 0, " ", ",");?></td>
</tr>
<tr>
<td>Sixten</td>
<td><?php echo number_format(1600, 0, " ", ","); ?></td>
<td><?php echo number_format(1000000000, 0, " ", ",");?></td>
</tr>
<tr>
<td>Penny</td>
<td><?php echo number_format(885, 0, " ", ","); ?></td>
<td><?php echo number_format(8900002, 0, " ", ","); ?></td>
</tr>
<tr>
<td>Petra</td>
<td><?php echo number_format(2400, 0, " ", ","); ?></td>
<td><?php echo number_format(398433889, 0, " ", ","); ?></td>
</tr>
<tr>
<td>Neu</td>
<td><?php echo number_format(4974, 0, " ", ","); ?></td>
<td><?php echo number_format(198433889, 0, " ", ","); ?></td>
</tr>
</tbody>
</table>
</body>