Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

olup

Cancelled
Oct 11, 2011
383
40
What's the Difference between event.preventDefault() and return false in jQuery.

The https://forums.macrumors.com/forums/web-design-and-development.58/ would be the more appropriate forum for this. ;)

event.preventDefault() cancels the default behavior, submitting a form on click or clicking a link.

Return false prevents events from bubbling up the DOM tree, therefore could be seen as follows:
Code:
function(e) {
  e.preventDefault();
  e.stopPropagation();
}

More on events can be read on Peter-Paul Kochs blog: http://www.quirksmode.org/js/events_order.html
 

rochow

macrumors member
Aug 20, 2013
64
17
You can read into why later; if you're newer to programming just always use preventDefault();
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.