I have a series of image thumbnails in a page. They are created using css sprites.
<div class="galleryImg1"></div>
<div class="galleryImg2 featured"></div>
<div class="galleryImg3"></div>
I was originally using id="galleryImg1"
but changed to using class="galleryImg1"
because the images may appear in multiple places on the same page and i wanted to avoid duplicate ids.
I have a jQuery selector to attach click events to all of these classes.
$("[class^=galleryImg]").click(function() {
// how do i get 'galleryImg2' and '2' here?
}
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?
(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.)