2

I am having trouble finding out how to do the following:

I want a counter at the top with the number of rows displayed and the number of total rows like this:

10/100 (Not a pager)

What do I trigger on?

I have a variable on $(document).ready() like this: var total = $('table').length; How do I trigger the current rows on a filter change?

I am using the tablesorter plugin.

4

1 回答 1

3

试试这个代码(演示),它使用filterEnd事件来更新行数显示:

var $count = $('.count'),
    $t = $('table'),
    $tr = $t.find('tbody tr'),
    update = function(){
        var t = $tr.filter(':visible').length + '/' + $tr.length;
        $count.html(t);
    };

$t
    .on('filterEnd', function () {
        update();
    })
    .tablesorter({
        theme: 'blue',
        widgets: ['zebra', 'filter'],
        initialized: function(){
            update();
        }
    });
于 2013-10-30T03:23:08.680 回答