【发布时间】:2017-10-30 15:10:47
【问题描述】:
我正在使用这个 jQuery 表格排序器:https://mottie.github.io/tablesorter/docs/index.html。 我像这样初始化排序:
$('.sortable').tablesorter();
我的桌子是这样的:
<table class="sortable" id="list-users">
<thead>
<tr>
<th>
<div class="sorter"></div>
ID
</th>
<th>
<div class="sorter"></div>
Name
</th>
<th>
<div class="sorter"></div>
Birth date
</th>
</tr>
</thead>
<tbody>
<tr>
...
默认行为如下:当我点击一个标签时,表格会根据列进行排序。这很好。
但是我想在点击 div.sorter 时触发事件。 有人知道怎么做吗? 我试过这个:
$('table').find('th:eq(columnNumber)').trigger('sort');
但这当然不会禁用默认事件,这在您想触发事件时很有用。
谢谢!
【问题讨论】:
标签: jquery tablesorter