這應該爲你工作(demo):
<table id="ex" class="tablesorter">
<thead>
<th class="sorter-false"></th>
<th>Name</th>
<th>Contribution</th>
</thead>
<!-- add an "info" only (non-sorting) tbody -->
<tbody class="tablesorter-infoOnly"></tbody>
<tbody class="names">
<tr>
<td><input type="checkbox" /></td>
<td>Warren Buffet</td>
<td>business</td>
</tr>
<!-- etc -->
</tbody>
</table>
代碼
$(function() {
$("#ex").tablesorter({ sortList: [[0,0], [1,0]] });
$('#ex').on('click', 'input:checkbox', function() {
var $this = $(this);
if ($this.is(':checked')) {
$this.closest('tr').prependTo("#ex .tablesorter-infoOnly");
} else {
$this.closest('tr').appendTo("#ex .names");
}
$this.trigger('update');
});
});
在 「名稱」 中選中行的實際位置(追加)TBODY並不重要,因爲它將被添加回來,當前的排序會被更新。
請您澄清一下。未選中的行是否被排序? – Mottie 2013-05-04 01:08:30
我希望未選中的複選框的行始終排序。 – user2229399 2013-05-04 12:03:26