title: Hide complete column if data is null or empty using jquery
body: <p>I would like to hide the complete column including the heading if data is empty or null. I tried to do this with jquery, but iam not able to accomplish what iam trying. Basically iam getting some records in PHP. Some columns doesnt have data, so i dont need to show the empty data or data which is NULL. Can anyone guide me on whats the mistake iam making.</p>
  
  <pre><code>&lt;html&gt;
  
  &lt;head&gt;
  &lt;title&gt;Hide&lt;/title&gt;
   &lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;table border="1" width="100%" id="mytable"&gt;
     &lt;thead&gt;
     &lt;tr&gt;
     &lt;th&gt;Head1&lt;/th&gt;
     &lt;th&gt;Head2&lt;/th&gt;
     &lt;th&gt;Head3&lt;/th&gt;
     &lt;/thead&gt;
     &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td&gt;aa&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;
  &lt;td&gt;cc&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;aa&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;
  &lt;td&gt;cc&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;aa&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;
  &lt;td&gt;cc&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  &lt;script type='text/javascript'&gt;
  $(window).load(function(){
  $('#mytable &gt; tbody  &gt; tr td:empty').parent().hide()
  if($td.text() == ''){
      $(this).hide();
      }
  });
  
  });
  
  &lt;/script&gt;
  </code></pre>