title: jQuery - select groups of child elements based on the parent DIV element
body: <p>I have a normal html page with stuff like divs and links with images:</p>
  
  <pre><code>&lt;div&gt;
    &lt;a href="foo.jpg"&gt; ... &lt;/a&gt;
    &lt;a href="boo.jpg"&gt; ... &lt;/a&gt;
  &lt;/div&gt;
  
  &lt;div&gt;
    &lt;a href="bah.jpg"&gt; ... &lt;/a&gt;
    &lt;a href="gah.jpg"&gt; ... &lt;/a&gt;
  &lt;/div&gt;
  
  ...
  </code></pre>
  
  <p>I'm trying to hook a lightbox script on all links that end with jpg/gif/png extensions.</p>
  
  <p>Right now, based on a previous question I asked :), I have:</p>
  
  <pre><code> $('div a').filter(function(){
     return this.href.match('[\.jpg|\.png|\.gif]$');
   }).colorbox({
     rel: 'gallery'
   });
  </code></pre>
  
  <p>which groups all links inside <code>gallery</code>.</p>
  
  <p>But I would want to group links from each div inside their own gallery. For example .foo' &amp; .boo links inside a <code>gallery1</code> and .bah &amp; .gah inside <code>gallery2</code> and so on...</p>
  
  <p>How can I do that?</p>