To identify your last page, try to get a specific information in your URL then you can try something like this in Javascript :
First find the last page index :
var itemsCount = 15 -->here you have to get the count of all your elements store in your datatable
var itemPerPage = 6 --> the datatable pagesize
var pageMax = Math.ceil(itemsCount/itemPerPage);
18 items / 6 per page = 3 pages
19 items / 6 per page = 4 pages
Get the index parameter in your URL (refer to this:How can I get query string values in JavaScript?) :
//if your url look like this : http://localhost:5555/home?index=5&pageSize=18
var urlParams = new URLSearchParams(window.location.search);
const myIndex= urlParams.get('index'); // = 3
if(pageMax == myIndex)
{
//hide your element <tfoot></tfoot>
}