Question · JavaScript and TypeScript course · Module 8: Events and the DOM

Deliberate use of preventDefault()

Why do we call e.preventDefault() in a form's submit event handler?

Answer options

  • To stop the default submission and page reload, and handle the form with custom code
  • To remove the form from the DOM
  • To clear the browser's memory
  • To change the form's method to GET

You can check the correct answer by solving this task in the CodeWorlds game.