I have a problem that i cannot resolve.
I'm adding a click event listener to a parent container and also to its child.
I need to take the info of both clicks but the problem is when the child container is clicked, the click event from the parent is also triggered.
I do not want that to happen. So, does anyone know how to avoid that behavior?
I want to record just when it is clicked in one or the other. Not in both at the same time. So far I've been trying with this options:
let validar = false;
parentCont.addEventListener('click',()=>{
validar = true;
pointControl();
});
childCont.addEventListener('click',()=>{
validar = false;
pointControl();
});
Also with the simple option:
parentCont.addEventListener('click',function);
childCont.addEventListener('click',function);
When the parent is triggered, the child obviously not. But when the child is triggered, the parent also is.
I tried with other things but also didn't work, maybe I'm doing something wrong. Anyway, thanks!