我正在使用 jQuery tablesorter plugin .我知道如何使用 jQuery 元数据插件禁用对列的排序:
<th class="{sorter: false}">Don't sort me</th>
但我宁愿通过设置一个类来做到这一点,这样我就不必使用额外的插件。另外我想我会比记住这个 JSON 语法更容易记住类名。我怎样才能使用这种语法做同样的事情:
<th class="not-sortable">Don't sort me</th>
最佳答案
您不必修改插件的源代码。假设你的 th 类不排序被称为 nosort:
function setupTablesorter() {
$('table.tablesorter').each(function (i, e) {
var myHeaders = {}
$(this).find('th.nosort').each(function (i, e) {
myHeaders[$(this).index()] = { sorter: false };
});
$(this).tablesorter({ widgets: ['zebra'], headers: myHeaders });
});
}
关于javascript - jQuery 表格排序器 : How to disable sorting on a column by using a class instead of "inline JSON"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6627737/