skip to Main Content

How can i use a button within a div created in javascript

let productDetails = document.createElement("div"); productDetails.className = "product_card"; productDetails.innerHTML = ` <img src="${product.image.desktop}" alt="${product.name}" /> <div class="button-wrapper"> <button id="btn_add_to_cart">Add to Cart</button> </div> <div class="product-details-wrapper"> <p id="product_category">${product.category}</p> <h4 id="product_name">${product.name}</h4> <p id="product_price">$${product.price.toFixed(2)}</p> </div>`; productList.appendChild(productDetails); I created a function to add product to a…

VIEW QUESTION
Back To Top
Search