How can I change visibility of rows in a table with jQuery?
<p>I have a table with a structure like this:</p>

<pre><code>&lt;tr&gt;
   &lt;td id="refKey_1" style="text-align:center;" class=" sorting_1"&gt;1.0.0&lt;/td&gt;
   &lt;td id="Title_1"&gt;
      &lt;input type="text" value="x" size="100" name="item.Title" id="item_Title_1"&gt;
   &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
   &lt;td id="refKey_2" style="text-align:center;" class=" sorting_1"&gt;1.2.0&lt;/td&gt;
  &lt;td id="Title_2"&gt;
      &lt;input type="text" value="xx" size="100" name="item.Title" id="item_Title_2"&gt;
   &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
   &lt;td id="refKey_3" style="text-align:center;" class=" sorting_1"&gt;1.3.4&lt;/td&gt;
   &lt;td id="Title_3"&gt;
      &lt;input type="text" value="xxx" size="100" name="item.Title" id="item_Title_3"&gt;
   &lt;/td&gt;
&lt;/tr&gt;
</code></pre>

<p>I am using the following jQuery to pad coloumns depending on the value of the column with 
id = refKey_x. This code looks at the value and pads rows differently depending if the value of refkey is "X.0.0" or "X.X.0" or "X.X.X".</p>

<pre><code>$('tr').each(function() {
    var tds = $(this).find('td'),
        text = tds.filter('[id^="refKey_"]').text(),
        tdToPad = tds.filter('[id^="Title_"]'),
        pad;
    if (/0\.0$/.test(text))
        pad=0;
    else if (/\.0$/.test(text))
        pad=10;
    else
        pad=20;
    tdToPad.css('paddingLeft', pad);
});
</code></pre>

<p>Is there a way that I could put two toggle buttons on my screen so that by clicking this it could show and hide the rows that meet the criteria for pad=10 and pad=20 rows?  </p>

<p>What I was thinking of was if the above could be changed so that in addition to adding a pad it could also change the class of the row to something like level-1, level-2 and level-3.  Then maybe I could have two buttons that could show or hide the rows with level-2 or level-3. </p>

<p>I would welcome any other suggestions as I am not sure my suggestion is the best way to go about doing what I need.</p>
