本文介绍了jQuery Tablesorter-通过单击链接进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery Tablesorter对表进行排序,并且一切正常.我想做的是在表格上方添加一个链接,该链接的内容类似于按价格排序",当用户单击链接时,我希望价格"列进行排序.此外,如果他们再次单击它,它将以另一种方式对价格进行排序.这可能吗?

I'm using jQuery Tablesorter to sort a table and everything works as expected. What I'd like to do is add a link above my table that says something along the lines of "Sort by Price" and when the user clicks the link I want the "Price" column to sort. Additionally, if they click it again, it would sort the price the other way. Is this possible?

谢谢!马诺伊

推荐答案

来自 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;
    });
});

这篇关于jQuery Tablesorter-通过单击链接进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 05:08
查看更多