Web Development
Create a link on each product cart? – JavaScript – SitePoint Forums
Good morning,
How can I create a link on each product in order to display a description for each product offered ?
My code html
<section class="section2" id="onlinestore"><br>
<h2>Online Store</h2><br>
<div class="inner">
<h2 style="color:#f1bc0d">All Coffee Beans</h2>
<!-- Item Cards -->
<div class="itemContainer" id="itemContainer"></div>
<div class="cartContainer" id="cartContainer">
<div id="closeCart">
<h3 class="closeCart">Close</h3>
</div>
<h1 id="cartTitle">No Item</h1>
<!-- each cart Container -->
<div id="eachCartItemContainer"></div>
<di id="totalPriceContainer">
<p>Total Price <span id="totalPrice"></span>€</p>
</di>
</div>
</div>
</section>
My code js
for (let index = 0; index < products.length; index++) {
const { id, productName, productPrice, productImg } = products[index]
itemContainer.innerHTML +=
` <div class="card">` +
` <article class="cardImg">` +
` <img src="https://www.sitepoint.com/community/t/create-a-link-on-each-product-cart/449366/./img/${productImg}" alt="">` +
`</article> ` +
` <div class="itemDescContainer">` +
`<article class="itemDesc">` +
`<h1 class="itemName">${productName}</h1>` +
`<p class="itemPrice">${productPrice}€</p>` +
` </article> ` +
`<div class="addtocart" id="addtocart${id}")'>` +
`<i class="fa-solid fa-cart-shopping cart"></i>` +
` </div>` +
` </div>` +
`</div>`
}
Thank you for your help.