Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery - filter child divs?
    text
    copied!<p>I wound up converting a table to just divs... But, in doing that, I need to rewrite a function and I'm having some issues... I've tried to implement $(this).closest('div'), but it's not doing what I thought that would do... Still reading, but if someone knows of a solution, I'd be a happy camper... </p> <p>Essentially, when I click on a link, it filters the table to only display rows with a class that matches the link's class... </p> <p>This is the code, which was originally created to filter a table... </p> <pre><code>&lt;a href="#" class="dairy"&gt;Dairy&lt;/a&gt; &lt;a href="#" class="meat"&gt;Meat&lt;/a&gt; &lt;a href="#" class="vegetable"&gt;Vegetable&lt;/a&gt; $('a').click(function(evt){ var myId = $(this).attr('class'); $('tr').each(function(idx, el){ if ($(el).hasClass(myId)) { $(el).show(); } else { $(el).hide(); } }); }); </code></pre> <p>I've since changed the table to divs:</p> <pre><code>&lt;div id="primary-div"&gt; &lt;div class="child dairy"&gt; &lt;div class="title"&gt;Title&lt;/div&gt; &lt;div class="text"&gt;Lorem ipsum&lt;/div&gt; &lt;/div&gt; &lt;div class="child dairy"&gt; &lt;div class="title"&gt;Title&lt;/div&gt; &lt;div class="text"&gt;Lorem ipsum&lt;/div&gt; &lt;/div&gt; &lt;div class="child meat"&gt; &lt;div class="title"&gt;Title&lt;/div&gt; &lt;div class="text"&gt;Lorem ipsum&lt;/div&gt; &lt;/div&gt; &lt;div class="child vegetable"&gt; &lt;div class="title"&gt;Title&lt;/div&gt; &lt;div class="text"&gt;Lorem ipsum&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Like I said, I'm still looking, but I'm being horribly unsuccessful... </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