Filter

1847 Tepper
document.querySelectorAll('article.product').forEach(function(product) { const variations = product.querySelectorAll('.variation-item'); const productImages = product.querySelectorAll('.product-list-item'); if(variations.length > 0) { variations.forEach(function(variation) { variation.addEventListener('click', function() { variations.forEach(function(image) { if(image.dataset.id === variation.dataset.id) { image.classList.add('active'); } else { image.classList.remove('active'); } }); productImages.forEach(function(image) { if(image.dataset.id === variation.dataset.id) { image.classList.add('active'); } else { image.classList.remove('active'); } }); }); }); } });