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

Dispatching an event

Which method do we use to "fire" a custom event on a DOM element?

Answer options

  • element.dispatchEvent(event)
  • element.addEventListener(event)
  • element.removeEventListener(event)
  • element.preventDefault(event)

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