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

Closing a modal by clicking the backdrop

In a modal component, how do you tell a click on the backdrop (overlay) from a click on the content?

Answer options

  • By checking e.target === modal in the click listener
  • By checking e.target.value
  • By using event.preventDefault()
  • By comparing e.timeStamp with the current time

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