I’m trying to make a generic shopping cart
So basically, I have a div that has multiple h2 elements within it.
on my button click i’m getting the entire container div which is what I want because I’m moving the entire div to the shopping cart on click.
However, there is an h2 within that div that I need to target specifically, and I don’t understand how to.
e.target.parentElement brings back the entire div on click.
I’m trying to add another property to go within that div and get the text content of the h2 within it.
Is there any way to do this? Sorry if it’s worded oddly
for (i=0; i<addToCartButtons.length; i++) {
addToCartButtons[i].addEventListener('click', (e) => {
cartContainer.innerHTML += e.target.parentElement.innerHTML
console.log(e.target.parentElement.)
})
}