Skip to content

Instantly share code, notes, and snippets.

@thinkphp
Last active April 18, 2025 13:10
Show Gist options
  • Save thinkphp/02b9db15e290e97510565bb87be20412 to your computer and use it in GitHub Desktop.
Save thinkphp/02b9db15e290e97510565bb87be20412 to your computer and use it in GitHub Desktop.
afisare produse
document.querySelectorAll('.add-to-cart-button').forEach(button => {
button.addEventListener('click', addToCart);
});
function afisare_produse() {
for (let i = 0; i < coffeeProducts.length; i++) {
const product = coffeeProducts[i];
const create_product_card = document.createElement("div");
create_product_card.classList.add("product-card");
const create_product_img = document.createElement("div");
create_product_img.classList.add("product-image");
create_product_img.textContent = product.name;
create_product_card.appendChild(create_product_img);
const create_product_info = document.createElement("div");
create_product_info.classList.add("product-info");
const create_product_title = document.createElement("h3");
create_product_title.classList.add("product-title");
create_product_title.textContent = product.name;
create_product_info.appendChild(create_product_title);
const create_product_price = document.createElement("div");
create_product_price.classList.add("product-price");
create_product_price.textContent = product.price;
create_product_info.appendChild(create_product_price);
const create_product_description = document.createElement("p");
create_product_description.classList.add("product-description");
create_product_description.textContent = product.description;
create_product_info.appendChild(create_product_description);
const create_btn_atc = document.createElement("button");
create_btn_atc.textContent = "Add to cart";
create_product_info.appendChild(create_btn_atc);
create_product_card.appendChild(create_product_info);
products_container.appendChild(create_product_card);
}
}
afisare_produse();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment