title: Finding matched classname in jQuery
body: <p>I have a series of image thumbnails in a page. They are created using css sprites.</p>
  
  <pre><code>&lt;div class="galleryImg1"&gt;&lt;/div&gt;
  &lt;div class="galleryImg2 featured"&gt;&lt;/div&gt;
  &lt;div class="galleryImg3"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>I was originally using <code>id="galleryImg1"</code> but changed to using <code>class="galleryImg1"</code> because the images may appear in multiple places on the same page and i wanted to avoid duplicate ids.</p>
  
  <p>I have a jQuery selector to attach click events to all of these classes.</p>
  
  <pre><code>$("[class^=galleryImg]").click(function() {
     // how do i get 'galleryImg2' and '2' here?
  }
  </code></pre>
  
  <p>What I'm wondering is if there is an easy way to find out the className beginning with 'galleryImg' that was clicked on. Will I have to use a regular expression or is there a 'cleverer' way?</p>
  
  <p>(yes if i was using an #ID selector then I could just say 'this.id' but as mentioned I don't want to use IDs because I want to display multiple copies of the same image.)</p>