title: Show/hide a table row based on nested class
body: <p>I have a button on a page that I want to only show rows that have a certain class (<code>target-class</code> in my example) within them. If you press the button again, then all rows are shown.</p>
  <p>I'm not sure how to check if <code>target-class</code> is within <code>&lt;tr class=&quot;show-hide-this-one&quot;&gt;</code></p>
  <pre><code>&lt;button id=&quot;btn-toggle_target&quot; type=&quot;button&quot;&gt;Show Targets Only&lt;/button&gt;
  &lt;table&gt;
      &lt;tbody&gt;
      {% for item in first_list %}
          &lt;tr class=&quot;show-hide-this-one&quot;&gt;
              &lt;td&gt; {{ item.title }} &lt;/td&gt;
              &lt;td&gt; 
                  &lt;table&gt;&lt;tbody&gt;
                  {% for subitem in item.sublist %}
                      &lt;tr&gt;
                          &lt;td&gt;
                              {{ subitem.value }}
                              {% if value == 0 %}
                                  &lt;span class=&quot;target-class&quot;&gt; Looking for this one &lt;/span&gt;
                              {% endif %}
                          &lt;/td&gt;
                      &lt;/tr&gt;
                   {% endfor %}
                   &lt;/tbody&gt;&lt;/table&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      {% endfor %}
      &lt;/tbody&gt;
  &lt;/table&gt;
  
  &lt;script type=&quot;text/javascript&quot;&gt;
  
      function toggleTarget() {       
          $btnToggle = $(&quot;#btn-toggle_target&quot;)
          var showTargetOnly = $btnToggle.hasClass(&quot;target-only&quot;)
          if (showTargetOnly) {
              $btnToggle.html(&quot;Show Targets Only&quot;).removeClass(&quot;target-only&quot;);
              $().show();
          }
          else {
              $btnToggle.html(&quot;Show All Records&quot;).addClass(&quot;target-only&quot;);
              $().hide();
          }
      }
  
      (function () {
          $(&quot;#btn-toggle_target&quot;).on('click', function() {
              toggleTarget();
          });
      }());
  
  &lt;/script&gt;
  </code></pre>