I am working on an e commerce website where I had to generate the html from javacript but also creating data. But the buttons are not working with the addEventListeners. It just wouldnt do anything even after i click on them.
`<div class="product-container">
<div class="product-image-con">
<img class="product-img" src="${bread.image}" alt="bread">
</div>
<div class="product-price">
$${bread.price}
</div>
<div class="product-name">
${bread.name}
</div>
<div class="sub-side">
<div class="product-insight">
<i class='bx bx-info-circle' ></i>
</div>
<div class="product-weight">
${bread.weight}
</div>
<button class="add-button button-primary js-add-to-basket"
data-product-id ="${bread.id}">
Add
</button>
</div>
</div>
`;
let addToBasket = document.querySelectorAll('.js-add-to-basket');
addToBasket.forEach((button)=>{
button.addEventListener('click', () =>{
console.log(button.dataset)
});
});