jQuery 数据表 单击按钮时删除分页



是否可以根据用户的操作更改初始化期间定义的数据表的属性?我不想销毁((表并再次创建或初始化。还有其他方法吗? 我想在用户单击按钮时从数据表中删除分页

$('#example').dataTable( {
"paging": true
} );
<button id="stopPaging"> Stop Paging<button>

我想在单击按钮时更改为"分页":false。 提前谢谢。

您可以通过将以下单击事件添加到您的 js 文件来调用禁用和隐藏分页。

$( "#stopPaging" ).click(function() {
$('#dataTables_paginate').find('a').each(function(e){
$(this).off('click');
$(this).parent().css("display","none")
})
});

希望这会有所帮助。

干杯

最新更新