如何使用 Datatables 操作 DOM 并更改搜索框位置

How to manipulate the DOM with Datatables and change the search box position

我一直在阅读 official documentation 并试图了解如何使用 DOM 操作更改默认搜索框的位置,但我无法使其工作。

LIVE DATATABLE DEMO

所以基本上我想要的是更改搜索框的位置并将其放置在 <input title="Search"... 代码中以保持相同的功能。

我虽然这样可以解决问题,但事实并非如此:

"dom": '<"#search"f>'

如有任何帮助,我们将不胜感激。

您可以使用

隐藏搜索字段
dom: 'lrt'

然后您需要使用

从您的字段中激活搜索
// I have added id="search" to your search field to make it easier
$('#search').on('input', () =>
{
    DT1.search($('#search').val()).draw();
});

这是工作fiddle

http://live.datatables.net/vepedopa/3/edit