I'm working on my E-commerce project. Here is something I am struggling to figure out...
If clicking on the "i" icon, a modal should open.
Code snippet
const products = [
{
id: 1,
title: 'Pens',
img: '/assets/images/Stationery Items/d-pens.jpg',
description: 'Pens',
rate: 4.2,
},
{
id: 2,
title: 'Notebooks',
img: '/assets/images/Stationery Items/d-notebooks.jpg',
description: 'Notebooks',
rate: 3.4,
},
{...}
]
function showProduct(product) {
return `
<div class="box-wrap border">
<img src="${product.img}" class="rounded d-block">
<div class="body">
<h5>${product.title}</h5>
<div class="d-flex justify-content-between">
<a href="#"><i class="fas fa-star"></i></a>
<a href="#"><i class="fas fa-info"></i></a>
</div>
</div>
</div>
`
}
function productList() {
document.getElementById('products').innerHTML = `
<div class="owl-carousel">
${products.map(showProduct).join('')}
</div>
`
}