Adding Class to first child of a group of parent elements using jQuery
<p>I've searched hi and low and after too many hours staring at the rest of this codebase, the answer to this seemingly simple function is eluding me.</p>

<p>HTML is as follows:</p>

<pre><code>&lt;a class="element-link local" data-category="local"&gt;
    &lt;img src="http://placehold.it/48x48/eee/eee.png"  class="logo" alt="" /&gt;
&lt;/a&gt;
&lt;a class="element-link local" data-category="local"&gt;
    &lt;img src="http://placehold.it/48x48/eee/eee.png"  class="logo" alt="" /&gt;
&lt;/a&gt;
&lt;a class="element-link news" data-category="news"&gt;
    &lt;img src="http://placehold.it/48x48/eee/eee.png"  class="logo" alt="" /&gt;
&lt;/a&gt;
&lt;a class="element-link news" data-category="news"&gt;
    &lt;img src="http://placehold.it/48x48/eee/eee.png"  class="logo" alt="" /&gt;
&lt;/a&gt;
&lt;a class="element-link business" data-category="business"&gt;
    &lt;img src="http://placehold.it/48x48/eee/eee.png"  class="logo" alt="" /&gt;
&lt;/a&gt;
&lt;a class="element-link business" data-category="business"&gt;
    &lt;img src="http://placehold.it/48x48/eee/eee.png"  class="logo" alt="" /&gt;
&lt;/a&gt;
&lt;a class="element-link business" data-category="business"&gt;
    &lt;img src="http://placehold.it/48x48/eee/eee.png"  class="logo" alt="" /&gt;
&lt;/a&gt;
&lt;a class="element-link business" data-category="business"&gt;
    &lt;img src="http://placehold.it/48x48/eee/eee.png"  class="logo" alt="" /&gt;
&lt;/a&gt;
</code></pre>

<p>What I'm trying to do is target the first child of each one of the categories, and to add a class to it. So, the FIRST news, business, etc. (for each category) will have a class added to it. For example this is the JS I have:</p>

<pre><code>$container.find('.element-link').each(function(){
    var category = $(this).data('category'); 
    $(this).hasClass(category).first().addClass('new');
});
</code></pre>

<p>I have tried various iterations of :first, :first-child, :eq(1) to no avail., and I'm out of coffee to boot. </p>

<p>Any help is greatly appreciated!
Thanks.</p>
