从表中删除jQuery tablesorter

我正在使用jQuery tablesorter(http://tablesorter.com)。

在通过$('#myTable').tablesorter()应用于表后,如何从表中再次删除它?

没有内置函数来执行此操作,但您可以删除类名称和事件绑定以停止其运行…尝试这样的事情:

 $('table') .unbind('appendCache applyWidgetId applyWidgets sorton update updateCell') .removeClass('tablesorter') .find('thead th') .unbind('click mousedown') .removeClass('header headerSortDown headerSortUp'); 

如果您正在运行寻呼机插件,则上述操作无效。

tablesorter2.0

 $("#table").trigger("destroy"); 

或者如果你只是需要在追加新的thead后更新所有内容:

 $("#table").trigger("updateAll"); 

– > http://mottie.github.io/tablesorter/docs/index.html

最新版本的表分拣库提供了Destroy方法

从版本2.16开始,在表分类器库中添加了destroy()方法,使用此方法从表中删除tablesorter。

使用下面给出的函数onclick删除短路元素的事件

 function removeTableShorter(){ $("#myTable").tablesorter({ headers: { 0: {sorter: false}, 1: {sorter: false}, 2: {sorter: false}, 3: {sorter: false}, 4: {sorter: false}, 5: {sorter: false} } }); $('#myTable th').removeAttr('class');} 

你可以根据表的列数增加标题的数量。