S sarahjoness macrumors newbie Original poster Dec 15, 2014 5 0 California Dec 10, 2015 #1 What's the Difference between event.preventDefault() and return false in jQuery.
O olup Cancelled Oct 11, 2011 383 40 Dec 11, 2015 #2 sarahjoness said: What's the Difference between event.preventDefault() and return false in jQuery. Click to expand... 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
sarahjoness said: What's the Difference between event.preventDefault() and return false in jQuery. Click to expand... 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
R rochow macrumors member Aug 20, 2013 64 17 Dec 12, 2015 #3 You can read into why later; if you're newer to programming just always use preventDefault();