Note that there are some explanatory texts on larger screens.

plurals
  1. POhiding jquery table columns with header anchor text value
    primarykey
    data
    text
    <p>I am trying to hide Table columns using jquery based on table>th>a text. My code only hides header and not the td columns related to header. I used to get index of th also but cant get exact solution. Could some one please help me on this issue. <a href="http://jsfiddle.net/6L5Jd/1/" rel="nofollow">This is what I tried in fiddle</a></p> <pre><code>Enter th names seperated by commas &lt;input type=text id=thVal &gt; &lt;input type=button value='hide entered th related columns' id=btnclick&gt; &lt;div id="tblMyProjects1" class="flexcroll"&gt; &lt;table id="tblMyProjects" width=100%&gt; &lt;thead&gt; &lt;tr&gt; &lt;th scope="col"&gt; &lt;a href="/Default/MyProjects?sort=ID&amp;amp;sortdir=ASC"&gt;ID&lt;/a&gt; &lt;/th&gt; &lt;th scope="col"&gt; &lt;a href="/Default/MyProjects?sort=Title&amp;amp;sortdir=ASC"&gt;Title&lt;/a&gt; &lt;/th&gt; &lt;th scope="col"&gt; &lt;a href="/Default/MyProjects?sort=ProjectType&amp;amp;sortdir=ASC"&gt;ProjectType&lt;/a&gt; &lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;10&lt;/td&gt; &lt;td&gt;Test Project ALTERED&lt;/td&gt; &lt;td&gt;test1&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;11&lt;/td&gt; &lt;td&gt;Test Project&lt;/td&gt; &lt;td&gt;test2&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;12&lt;/td&gt; &lt;td&gt;Test Project&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;13&lt;/td&gt; &lt;td&gt;pJPgOjDP&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;14&lt;/td&gt; &lt;td&gt;Tve4Odmmm&lt;/td&gt; &lt;td&gt;test 3&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;15&lt;/td&gt; &lt;td&gt;MDq6pQZG4Y&lt;/td&gt; &lt;td&gt;tst 4&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;16&lt;/td&gt; &lt;td&gt;hkfeIDz06Z&lt;/td&gt; &lt;td&gt;test 5&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;17&lt;/td&gt; &lt;td&gt;TestAutomationeHuthBrG&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;18&lt;/td&gt; &lt;td&gt;TestAutomationZIv8k48KJv&lt;/td&gt; &lt;td&gt;test7&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;19&lt;/td&gt; &lt;td&gt;TestAutomationjy6J8FrD&lt;/td&gt; &lt;td&gt;testing&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/div&gt; function hidecolumn(columns) { var table = $('#tblMyProjects'); var findColumn = $(table.find('th:contains(' + columns + ')')); var index = findColumn.index(); findColumn.hide(); $(table.find('tbody td:eq(' + index + ')')).hide(); } $('#btnclick').click(function(){ $('#tblMyProjects &gt; tbody').each(function(){ hidecolumn($('#thVal').val()); }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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