我正在使用Mottie的Tablesorter(https://github.com/Mottie/tablesorter),我試圖在格式化的單元格上使用Math小部件;Tablesorter數學小部件使用數據*
<td data-number="50">Fifty</td>
但是我似乎無法找出如何通過對arry
在math-complete
選項傳遞data-*
;
math_complete : function($cell, wo, result, value, arry) {
var txt = '<span class="align-decimal">' +
(value === wo.math_none ? '' : '$ ') +
result + '</span>';
if ($cell.attr('data-math') === 'all-sum') {
// when the "all-sum" is processed, add a count to the end
return txt + ' (Sum of ' + arry.length + ' cells)';
}
return txt;
}
此外,我使用v2.18.2。
http://stackoverflow.com/questions/4187032/get-list-of-data-attributes-using-javascript-jquery –
我要求將它集成到TableSorter中,因爲我希望使用'math_event'選項。這個解決方案只是一個通用的jQuery解決方案。 – psycotik