gpt4 book ai didi

jQuery tablesorter 对逗号分隔的数字进行排序

转载 作者:行者123 更新时间:2023-12-01 00:41:09 25 4
gpt4 key购买 nike

我正在使用 jQuery Tablesorter 2.0 (http://tablesorter.com/docs/)。对数字进行排序工作正常,但是一旦我添加

number_format($count);

对于我的代码,排序不再起作用。排序如下:

810,208 -> 7,671,897 -> 2,329,439

而不是

7,671,897 -> 2,329,439 -> 810,208

有办法解决这个问题吗?我需要逗号分隔的数字以便更好地阅读。谢谢

最佳答案

http://www.christianmontoya.com/2008/11/14/extending-jquery-tablesorter-to-support-comma-delimited-numbers/

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"
});

关于jQuery tablesorter 对逗号分隔的数字进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10984609/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com