OiO.lk Blog jQuery hide elements according to index position using jquery
jQuery

hide elements according to index position using jquery


I have a dynamic table with many columns and rows. In some cells there is specific value "N/A".
I want to hide cells containing "N/A" along with its table header too
How is it possible using jquery

I tried this code and it works partially. Table cells were hidden perfectly but only first table header "material" is hidden.

jQuery(document).ready(function() {
  var findna = jQuery('tr').find('td:contains(N/A)').index();
  jQuery('tr').find('td:contains(N/A)').css('display', 'none');
  jQuery('table tr:first-child')
    .find("th:eq(" + findna + ")").css('display', 'none');

  console.log(findna)
});



You need to sign in to view this answers

Exit mobile version