TableSorter. Sort by Dropdown selection

别等时光非礼了梦想. 提交于 2019-12-01 09:34:42

Maybe this is what you wanted (demo)?

HTML

<select>
    <option value="-">Choose a column</option>
    <option value="0">column 1c</option>
    <option value="1">column 2</option>
    <option value="2">column 3</option>
    <option value="3">column 4</option>
</select>

<table class="tablesorter">
    <!-- stuff here -->
</table>

Script

$(function(){
  $('table').tablesorter();

  $('select').change(function(){
    var column = parseInt($(this).val(), 10),
      direction = 1, // 0 = descending, 1 = ascending
      sort = [[ column, direction ]];
    if (column >= 0) {
      $('table').trigger("sorton", [sort]);
    }
  });
});

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!