我正在使用tablesorter进行开发,我的问题是:
是否有方法显示筛选后的数字列之和?
例如:
+++++++++++
名钱
+++++++++++
艾伦- 10
艾伦- 10
艾伦- 10
艾伦- 10
约翰- 10
约翰- 10
约翰- 10
金额: 70
如果我过滤名字,只显示“艾伦”,我想得到这个:
+++++++++++
名钱
+++++++++++
艾伦- 10
艾伦- 10
艾伦- 10
艾伦- 10
金额: 40
(谢谢你的帮助:)
发布于 2014-03-27 21:21:49
试试这个..。以下是来自这个演示的HTML
<table class="tablesorter">
<thead>
<tr>
<th>Name</th>
<th>Money</th>
</tr>
</thead>
<tbody>
...
</tbody>
</table>Sum of Money: <span class="total"></span>以及必要的脚本:
$('table')
.on('initialized filterEnd', function(){
var total = 0;
$(this).find('tbody tr:visible').each(function(){
// find money in 2nd column
total += parseFloat( $(this).find('td:eq(1)').text() );
});
$('.total').text(total);
})
.tablesorter({
theme: 'blue',
widgets: ['filter']
});https://stackoverflow.com/questions/22674636
复制相似问题