1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
// Je commence par trouver le ca_id en dehors de la boucle.
const trouve_ca_id = document.querySelector('img.picture');
const idImg = trouve_ca_id.id.split ('X');
var ca_id = idImg[0]; // modif 1
// puis j'envoie la boucle avec ton code
const imaxes = document.querySelectorAll('img.picture, img[src^="im/mu/' + ca_id + '-"] + img');
imaxes.forEach(imax => {
const tist = imax.alt;
const idImg = imax.id.split('X');
if (idImg.length < 3) {return;}
ca_id = idImg[0]; // modif 2
const height = idImg[1];
const img_format = idImg[2];
imax.addEventListener('click', function() {PopGrand(ca_id, tist, height, img_format);});
});
// Et j'ai un ca_id propre pour les scripts suivants.
let idPreco = document.getElementById ('F'+ ca_id); |