【发布时间】:2010-01-07 22:02:39
【问题描述】:
我正在使用 jQuery Tablesorter 对表格进行排序,一切都按预期工作。我想做的是在我的表格上方添加一个链接,上面写着“按价格排序”的内容,当用户单击该链接时,我希望“价格”列进行排序。此外,如果他们再次单击它,它将以另一种方式对价格进行排序。这可能吗?
谢谢! 马诺吉
【问题讨论】:
标签: jquery jquery-plugins tablesorter
我正在使用 jQuery Tablesorter 对表格进行排序,一切都按预期工作。我想做的是在我的表格上方添加一个链接,上面写着“按价格排序”的内容,当用户单击该链接时,我希望“价格”列进行排序。此外,如果他们再次单击它,它将以另一种方式对价格进行排序。这可能吗?
谢谢! 马诺吉
【问题讨论】:
标签: jquery jquery-plugins tablesorter
$(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;
});
});
【讨论】: