I have this code that fills me with an array which displays two images.
for (img of transactionImages) {
let image = document.createElement("img");
//$(image).addClass("box_imgpeque");
$(image).attr("src", "data:image/jpeg;base64," + img);
diImages.append(image);
}
I need to add a different class to each image.
for (img of transactionImages) {
let image = document.createElement("img");
$(image).attr("src", "data:image/jpeg;base64," + img);
$("#diImages img").addClass("imagen1");
if($("#diImages img").hasClass("imagen1")){
$("#diImages img").addClass("imagen2");
} else {
$("#diImages img").addClass("imagen1");
}
}
Try several things, in the latter what you do adds the classes, but to the first element you add the two
Is there any way in which a for cycle adds a class to each different element?
Thanks