Know if a click has been done inside a parent

Let's assume that you have the following HTML structure:

<div class = 'Family'>
    <div class = 'Dad' id = 'Dad'>
        <div class = 'Child'>I'm a child</div>
            <div class = 'Subchild'>I'm a subchild</div>
        <div class = 'Child'>I'm a child</div>
    <div class = 'Uncle'>I'm the uncle</div>

If you want to know if the click has been done inside the parent element:

const handleClick = (e) => {
    let parent = document.getElementById('Dad');
        alert('Dad sponsors the click');

window.addEventListener('click', handleClick);

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.