DEV Community

Discussion on: What is preventDefault() in JS?

Collapse
 
reritom profile image
Tomas Sheers

Thank you for that reply.

I hadn't heard of stopPropagation and hadn't really considered event bubbling. You're reply got me reading all through developer.mozilla.org/en-US/docs/L...

My question wasn't very clear and that Mozilla link, while really useful, also doesn't answer it. So I'll try to rephrase.

If you register an event listener with a handler, you have the option of being passed the event object. When your event handler gets called, when bubbling, does the engine then check to see whether the event handler called preventDefault/stopPropagation to determine whether to pass the event object to the next event handler?

And another question. In the case of, for example, a form. When you click submit and you want to preventDefault with your handler, is there default event handler lower in the chain of progression of the event that we are then blocking, or is it something else?

The way the event gets passed between handlers implicitly seems to be confusing me.

None the less, this article and your reply have been interesting to me.