DEV Community 👩‍💻👨‍💻

Discussion on: Event Capturing and Bubbling in React

Collapse
eladtzemach profile image
Elad Tzemach Author • Edited on

I'm happy to hear you have found this article to be useful!

In regards to your question - imagine you have the following:

<div onClick=...>
   <span id="1" onClick=...> ... </span>
   <span id="2" onClick=...> ... </span>
   <span id="3" onClick=...> ... </span>
</div>
Enter fullscreen mode Exit fullscreen mode

If you want the onClick of both the span and div to be triggered when you click on the span, except for when it's the span with id of 2, how can you achieve that?

My suggestion was that one option is to write information to the event object of that span, so then the div event handler can read it, see that it's the span with id of 2, and then not trigger its own event handler.

I hope it makes sense!

Collapse
varuns924 profile image
Varun S

Yes, I now see the application, thank you!

Collapse
aderchox profile image
aderchox

How do you write information to the event object? With event.someProp = value?