我正在尝试使用tablesorting插件对表中的数据进行排序,但数据使用逗号(,)作为分隔符,因此无法正确排序。我认为它将数字视为字符串。在谷歌的帮助下,我找到了一些代码,但这些代码对我不起作用。
$(document).ready(function(){
jQuery.tablesorter.addParser({
id: "fancyNumber",
is: function(s) {
return /^[0-9]?[0-9,\.]*$/.test(s);
},
format: function(s) {
return jQuery.tablesorter.formatFloat( s.replace(/,/g,'') );
},
type: "numeric"
});
$("#myTable").tablesorter({
widgets : ['zebra']
});
});
请告诉我我做错了什么。
我已经上课了
<th width="62" class="{sorter: 'fancyNumber'}">column</th>
也可以添加到柱中。