How to assign an ID to the search input using datatable.net

By FoxLearn 2/2/2024 6:55:07 AM   167
How to assign an ID to the global search box using datatable.net

If you want to assign an id on focus

$(document).ready( function () {
  var table = $('#dt').DataTable();
  
  $('#dt_filter label input').on( 'focus', function () {
    this.setAttribute( 'id', 'search' );
  });
} );

If you want to assign id when data is finished loading

initComplete : function() {
       $("#dt_filter input").prop( 'id', 'search_box' );
  },