To target an elements parent element using event.target with JavaScript, we use the parentNode
property.
For instance, we write
const handleEvent = (e) => {
const parent = e.currentTarget.parentNode;
};
to define the handleEvent
function.
It it, we get the current element that triggered the event with e.currentTarget
.
And we get its parent node with the parentNode
property.