jquery tablersorter 常用配置

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'],
       })

 
 

 

你可能感兴趣的:(jquery tablersorter 常用配置)