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

Viewed 67

I've been reading the official documentation and trying to understand how to change the location of the default search box with DOM manipulation but I couldn't make it work.

LIVE DATATABLE DEMO

So basically what I want is to change the location of the search box and place it within the <input title="Search"... code keeping the same features.

I though this would do the trick, but it doesn't:

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

Any help would be appreciated.

1 Answers

You can hide the search field with

dom: 'lrt'

and then you need to activate the search from your field with

// I have added id="search" to your search field to make it easier
$('#search').on('input', () =>
{
    DT1.search($('#search').val()).draw();
});

Here is the working fiddle

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

Related