How to apply the script to the first two values(not filtered) datatables.js?

there is such an example https://datatables.net/extensions/fixedheader/exam...
I use it part of the script is a duplicate thread and adds input filter

$(document).ready(function() {
 // Setup - add a text input to each footer cell
 $('#example thead tr').clone(true).appendTo( '#example thead' );
 $('#example thead tr:eq(1) th').each( function (i) {
 var title = $(this).text();
 $(this).html( '<input type="text" placeholder="Search '+title+'" />' );

 $( 'input', this ).on( 'keyup change', function () {
 if ( table.column(i).search() !== this.value ) {
table
.column(i)
 .search( this.value )
.draw();
}
 } );
 } );

 var table = $('#example').DataTable( {
 orderCellsTop: true,
 fixedHeader: true
 } );
} );


tell me how to generate the first 2 input , so they didn't have? name and position
March 19th 20 at 08:51
2 answers
March 19th 20 at 08:53
Solution
$('#example thead tr:eq(1) th').slice(2).each(... then everything is as it was

UPD. Moved from comments:

not going to fly, that is visually all right but in fact the search filter did not work in that column

Well, probably it is necessary the two to add to the index in each, not a table.column(i), and table.column(i + 2). Or not to rely on the index passed in and calculate it yourself, something like const index = $(this).closest('th').index().
sorry this plugin is not going to fly, that is visually all right but in fact the search filter did not work in that column , maybe just to hide these input? - icie2 commented on March 19th 20 at 08:56
added response - Lilly commented on March 19th 20 at 08:59
March 19th 20 at 08:55
Solution
$('#example thead tr:eq(1) th').each( function (i) {
 if (i > 1){
 var title = $(this).text();
 $(this).html( '<input type="text" placeholder="Search '+title+'" />' );

 $( 'input', this ).on( 'keyup change', function () {
 if ( table.column(i).search() !== this.value ) {
table
.column(i)
 .search( this.value )
.draw();
}
 } );
}
} );


either

$('#example thead tr:eq(1) th:nth-child(n+3)').each( function (i) {
// ...
});
sorry this plugin is not going to fly, that is visually all right but in fact the search filter did not work in that column , maybe just to hide these input? - icie2 commented on March 19th 20 at 08:58
@icie2prokanaet , just use my first example - marley_Kle commented on March 19th 20 at 09:01

Find more questions by tags jQuery