I am trying to get the class name from a selection of images when clicked.
The code below retrieves the first name of the image class, but when I click on other images with different class values, they display the first image class.
How can I get each value of an image class?
HTML
<a href="#" title="{title}" class="bg"><img src="{image:url:small}" alt="{title}" class="{image:url:large}" /></a>
JQuery code
$(".bg").click(function(){
var1 = $('.bg img').attr('class');
Jemes source
share