Student-friendly HTML, CSS, and JavaScript reference with examples
Gets the parent element that contains this element.
const deleteBtn = document.querySelector('.delete-btn');
const item = deleteBtn.parentElement;
deleteBtn.addEventListener('click', function() {
item.remove(); // Remove the parent
});
Useful for removing an entire container when clicking a button inside it.