Change class on click in repeat region

Hi.
I’ve a repeat region displaying images thumbs. Clicking on each thumb it pass the ‘src’ value to a form, and it works. I’m trying to change the class ONLY on the thumbs on which the user had clicked on.
I’ve tryed something like this:

$(document).ready(function () {
  var selectedImgsArrASCOD = new Array();
  $("#ASCOD").click(function () {
    $("#ASCOD").not(this).removeClass("selected-image-base");
    $(this).toggleClass("selected-image-base");
  });
});

but it doesn’t work. Anyone can help me?

Hello,
You can use a variable, to toggle the class depending on the selected image.

  1. Create a variable in app structure
  2. Select your image, add new dynamic event > click > variable > set value. Select $index from the repeat region as a value.
  3. With the image still selected, add new dynamic attribute > style > class toggle. Enter your class name, and for the condition use $index == yourvariable.value

Thanks!
It works!

1 Like