jQuery Tablesorter – 通过单击链接进行排序

我正在使用jQuery Tablesorter对表进行排序,一切都按预期工作。 我想要做的是在我的表格上方添加一个链接,该链接显示“按价格排序”的行,当用户点击链接时,我希望“价格”列进行排序。 此外,如果他们再次点击它,它会以另一种方式对价格进行排序。 这可能吗?

谢谢! 马诺

来自tablesorter.com

$(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; }); });