Is there any significant difference between event.preventDefault() vs. return false to stop event propagation?

Technology CommunityCategory: jQueryIs there any significant difference between event.preventDefault() vs. return false to stop event propagation?
VietMX Staff asked 3 years ago
  • return false from within a jQuery event handler is effectively the same as calling both e.preventDefault and e.stopPropagation on the passed jQuery.Event object.
  • e.preventDefault() will prevent the default event from occuring, e.stopPropagation() will prevent the event from bubbling up and return false will do both. Note that this behaviour differs from normal (non-jQuery) event handlers, in which, notably, return false does not stop the event from bubbling up.