jQuery.tablesorter 2.0中文排序解决办法
jQuery.tablesorter 2.0中文排序解决办法,jQuery.tablesorter 2.0中文排序使用的sortText方法,使用js操作符号<>进行对比,<>操作符号对中文无效,导致排序出问题。需要更改为localeCompare。jQuery.tablesorter 2.0新增了textSorter配置,改写内部的文字排序,可以增加此配置而不需要更改jQuery.tablesorter 2.0源代码。
jQuery.tablesorter未配置textSorter配置,使用jQuery.tablesorter默认方法中文排序错误
jQuery.tablesorter配置textSorter配置,中文排序正确
textsorter配置:http://mottie.github.io/tablesorter/docs/index.html#textsorter
$("table").tablesorter({ theme: 'blue', textSorter: function (a, b, asc, table) { return a.localeCompare(b);//jQuery.tablesorter 2.0中文排序解决办法 } });
加支付宝好友偷能量挖...
原创文章,转载请注明出处:jQuery.tablesorter 2.0中文排序解决办法