1,汉字排序
$(function(){
$("table").tablesorter({
//配置为localeCompare比较方式
textSorter: function(a, b, direction, columnIndex, table){
return a.localeCompare(b);
}
});
});
2,固定序号
$.tablesorter.addWidget({
id: 'fixFirstNumber',
format: function(table, config, widgetOptions, initFlag) {
for(var i=1;i<table.rows.length;i++){
//console.log(table.rows[i].cells[0].innerHTML);
table.rows[i].cells[0].innerHTML = i;
}
}
});
$("table").tablesorter({
widgets: ['fixFirstNumber'],
})
本文介绍了一种使用JavaScript实现的表格数据汉字排序方法及如何让表格中的序号随排序变化而自动更新的技术细节。
7736

被折叠的 条评论
为什么被折叠?



