jQuery的的tablesorter - 排序通过单击链接
-
19-09-2019 - |
题
我使用jQuery的tablesorter排序表,一切按预期工作。我想要做的就是增加我的桌子上方的链接,说线沿线的“按价格排序”的东西,当用户点击我想要的“价格”列进行排序的链接。此外,如果再次单击它,它会排序价格的另一种方式。这是可能的?
谢谢! 的Manoj
解决方案
$(document).ready(function() {
$("table").tablesorter();
$("#trigger-link").click(function() {
// set sorting column and direction, this will sort on the first and third column the column index starts at zero
var sorting = [[0,0],[2,0]];
// sort on the first column
$("table").trigger("sorton",[sorting]);
// return false to stop default link action
return false;
});
});
不隶属于 StackOverflow