i wanna delete onclick the item in localstorage but the algo delete always the first element not the item clicked on in the html view
var array = [...deleteButton]
array.forEach((item, index) =>
{
var id = item.parentElement.parentElement.parentElement.dataset.id
item.addEventListener("click", () =>
{
cart.forEach(elem =>
{
if(id === elem[0])
{
console.log(cart);
cart.splice(elem, 1);
location.reload();
console.log(cart);
localStorage.setItem("cart", JSON.stringify(cart))
console.log(index, elem[0]);
console.log(cart);
}
});
})
});