Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Like this?</p> <pre><code>$(function(){ var $table = $('#report'); function passTh(nm) { var th = "." + nm; var idx = $(th).index(); $table.find('tr :nth-child(' + (idx+1) + ')').hide(); } passTh('first_name'); }); </code></pre> <p><strong><a href="http://jsfiddle.net/A532E/" rel="nofollow">Demo</a></strong></p> <p>Since you want to hide th and tr you can select them with <code>nth-child</code> which takes elements based on index with base 1.</p> <p><em>UPDATE</em></p> <p>Since you have a large table, you can make it more effective with the help of css.</p> <p>Your Html:</p> <pre><code>&lt;table id="report"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th class="first_name"&gt;First Name&lt;/th&gt; &lt;th class="last_name"&gt;Last Name&lt;/th&gt; &lt;th class="email"&gt;Email&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class="first_name"&gt;Larry&lt;/td&gt; &lt;td class="last_name"&gt;Hughes&lt;/td&gt; &lt;td class="email"&gt;larry@gmail.com&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="first_name"&gt;Mike&lt;/td&gt; &lt;td class="last_name"&gt;Tyson&lt;/td&gt; &lt;td class="email"&gt;mike@gmail.com&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>Add this Css:</p> <pre><code>#report.first_name_hide .first_name, #report.last_name_hide .last_name, #report.email_hide .email { display:none; } </code></pre> <p>And just this JS which just adds a class on to a table:</p> <pre><code>$(function () { var $table = $('#report'); function passTh(nm) { var hide = nm + "_hide"; $table.addClass(hide); } passTh('first_name'); }); </code></pre> <p><strong><a href="http://jsfiddle.net/XejLC/" rel="nofollow">Demo</a></strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload