Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up

What is the difference between stopPropagation() and preventDefault()?

  1. A stopPropagation halts the event travelling through the DOM; preventDefault cancels the browser's default action
  2. B They do the same thing
  3. C preventDefault stops bubbling
  4. D stopPropagation removes the listener
Answer

stopPropagation halts the event travelling through the DOM; preventDefault cancels the browser's default action

They are unrelated. Preventing a link from navigating requires preventDefault, while stopping an ancestor handler from firing requires stopPropagation.

All Front end Development MCQs

Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up as