← Quiz: DOM and Events: all 10 questions
Quiz: DOM and Events · Question 2 of 10
Why call event.preventDefault() in a form submit handler?
Why call event.preventDefault() in a form submit handler?
- A.To clear the form
- B.To stop the browser from reloading the page / sending the form normally
- C.To stop other listeners
- D.To validate the form
Answer & explanation
Correct answer: To stop the browser from reloading the page / sending the form normally
Without it, the page navigates away before your JavaScript finishes.
Can you get the rest right without peeking?
Take the timed Quiz: DOM and Events quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →