[Solved] How to remove empty th and td from thead and tbody from the HTML table which has no id, Jquery or Javascript


Try this: you can use parent div selector to find the table and then its header and td elements to check if these elements are empty and delete it

$(function(){
  $("div.ui-datatable-tablewrapper table[role=grid] thead tr th").each(function(){
      var text = $(this).text();
      if(!text && !$(this).find('input').length)
     { 
       $(this).remove();
     }
  });

$("div.ui-datatable-tablewrapper table[role=grid] tbody tr td").each(function(){
      var text = $(this).text();
      if(!text && !$(this).find('input').length)
     { 
       $(this).remove();
     }
  });
});

2

solved How to remove empty th and td from thead and tbody from the HTML table which has no id, Jquery or Javascript