编辑**这个问题是关于我已经解决的其他问题。但现在我遇到了这个新问题。
我正在尝试将 tabletools 按钮移到表格之外,在自定义 div 内。我已经用下面的代码做到了:
<div class="table-wrap">
<div class="show-export"></div>
<table id="" class="tab-display tab-search export">
<thead> ...
</thead>
<tbody> ...
</tbody>
</table>
</div>
$('.tab-display').DataTable({
dom: '<"bottom"i>rt<"bottom"lp>T<"clear">',
fnInitComplete: function ( oSettings ) {
var otb = $(".DTTT_container")
$(".show-export").append(otb);
}
});
但是发生的事情是,按钮被重复了,因为我在一页中有多个表格。如果我只有一个表,它可以正常工作,但不能用于多个表。
有问题的img:
此外,如果我提供以下 jquery 代码来显示/隐藏 div,则按钮不起作用。
$(".show-export").hide();
$(".bt-export").change(function(tablef) {
var toShow = this.checked;
$(this).closest(".wrap-export").find(".show-export")[toShow ? "show" : "hide"](500);
});
我知道这与 fnResizeButtons 有关。但我只找到了使用选项卡而不是隐藏/显示 jquery 函数的解决方案。
谁能帮我?