Which method can be used to stop the event from propagating in the capturing or bubbling phase?

  • event.stopPropagation()
  • event.preventDefault()
  • event.stopPropagationPhase()
  • event.cancelPropagation()
The event.stopPropagation() method is used to stop the event from propagating further in the DOM tree. It prevents both capturing and bubbling phases, ensuring that the event doesn't trigger any other event listeners on the same element or its ancestors. This can be helpful in controlling event flow.
Add your answer
Loading...

Leave a comment

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