Stop parent from catching child event in JS | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Stop parent from catching child event in JS

I have a parent Div that has a click event. There are multiple child divs that have there own events. When clicking on a child both the child and the parent events get triggered (bubbling) I did add Event.stopPropogatio() in child elements which works tbh.. But I was wondering if it is possible to do something about the parent element so it ignores events bubbling from its children, or in other words the parents should only react to its own events. Not sure about if its a duplicate question.. Needed to ask in hurry

18th May 2021, 8:09 AM
Maymoona Ali Al-Boloshi
Maymoona Ali Al-Boloshi - avatar
2 Answers
+ 1
In the beginning Check the clicked element from the event arguments
18th May 2021, 8:40 AM
Toni Isotalo
Toni Isotalo - avatar