What's the difference between event.preventDefault() and event.stopPropagation() methods?

The event.preventDefault() method prevents the default behavior of an element. If used in a form element it prevents it from submitting. If used in an anchor element it prevents it from navigating. If used in a contextmenu it prevents it from showing or displaying. While the event.stopPropagation() method stops the propagation of an event or it stops the event from occurring in the bubbling or capturing phase.

Author of content
Edit this page

Made by Michael Sakhniuk