/    Sign up×
Community /Pin to ProfileBookmark

IE problems: Dynamically generated carousel not showing elements

I’ve created a dynamically generated carousel in JavaScript, where i use a for loop to iterate over an array of products and create a container div, img/title/ nodes and then append all of that to a root div i have on my markup. It works for all the main browsers (even Edge) EXCEPT IE. I’ve searched and tried many things but still not showing the elements i generate, and the console doesnt show anything wrong.

HTML:
<div class=”carousel-view” id=”carousel-view”></div>

JS:
carouselItems(productData) {
let carousel = this.carousel();

for (let i = 0; i < productData.length; i++) {
let product = document.createElement(‘div’);
product.setAttribute(‘class’, ‘product’);
product.setAttribute(‘id’, ‘product’ + i);
let a = document.createElement(‘div’);
a.setAttribute(‘id’,’product-link’);
// modal
a.addEventListener(‘click’, () => {
console.log(“item”, productData[i]);
this.productCallback(productData[i]);
});
let img = document.createElement(‘img’);
let title = document.createElement(‘p’);
// title.setAttribute(‘class’, ‘product-title’);
title.id = ‘product-title’;
let price = document.createElement(‘p’);
price.setAttribute(‘class’, ‘product-price’);

// a.appendChild(img);
// a.appendChild(title);
product.appendChild(a);
product.appendChild(price);
carousel.appendChild(product);
a.href = productData[i].productUrl;
img.src = productData[i].imageSrc;

}
}

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @lucyvfr spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...