JavaScript · Junior · Question 41 of 75
What does event.preventDefault() do?
- ✓Correct answer: Cancels the browser's default action (navigation, form submission)
- 2Stops the event from bubbling up to parent elements
- 3Removes the event handler from the element after the first call
Explanation
For example, a link won't follow its href, a form won't submit, a checkbox won't toggle. Stopping bubbling is event.stopPropagation(); they're different things and often confused.