File size: 1,166 Bytes
83c3a4e
 
1cf9796
83c3a4e
 
 
 
 
 
739c018
83c3a4e
 
 
739c018
83c3a4e
 
 
 
 
 
c49a8ad
83c3a4e
cc0a382
83c3a4e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
document.addEventListener('DOMContentLoaded', () => {
    const productsSection = document.getElementById('products');

    const products = [
        { id: 1, name: 'Product 1', image: 'https://via.placeholder.com/150', price: 19.99 },
        { id: 2, name: 'Product 2', image: 'https://via.placeholder.com/150', price: 29.99 },
        { id: 3, name: 'Product 3', image: 'https://via.placeholder.com/150', price: 39.99 },
        { id: 4, name: 'Product 4', image: 'https://via.placeholder.com/150', price: 49.99 },
    ];

    products.forEach(product => {
        const productDiv = document.createElement('div');
        productDiv.classList.add('border', 'p-4', 'rounded-md');

        productDiv.innerHTML = `

            <img src="${product.image}" alt="${product.name}" class="w-full h-40 object-cover mb-2">

            <h3 class="text-lg font-bold">${product.name}</h3>

            <p class="text-gray-700">$${product.price}</p>

            <button class="bg-amazon-orange hover:bg-yellow-500 text-white font-bold py-2 px-4 rounded mt-2">Add to Cart</button>

        `;

        productsSection.appendChild(productDiv);
    });
});