Question · JavaScript and React course · Module 3: State and Events
stopPropagation vs preventDefault
What is the difference between e.stopPropagation() and e.preventDefault()?
Answer options
- stopPropagation stops bubbling to the parent, preventDefault blocks the browser's default behavior
- Both methods do the same thing - they stop the event
- stopPropagation blocks default behavior, preventDefault stops bubbling
- stopPropagation only works on forms, preventDefault on all elements
You can check the correct answer by solving this task in the CodeWorlds game.