Which property of the event object is commonly used to prevent the default action of the event?

  • event.stopPropagation()
  • event.preventDefault()
  • event.cancelBubble()
  • event.halt()
To prevent the default action of an event in JavaScript, you commonly use the event.preventDefault() method. It stops the default behavior associated with the event, such as preventing a form from submitting or a link from navigating to a new page. This method is crucial for controlling the behavior of events.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *