Net-informations.com
SiteMap  | About    

event.preventDefault() Vs. return false



When you return false; from an event handler it prevents the default action for that event and stops the event bubbling up through the DOM. It is effectively the same as calling both e.preventDefault and e.stopPropagation on the passed jQuery.Event object.

event.preventDefault() mthod

jQuery e.preventDefault() will prevent the default event from occurring.

example

  1. Prevent a submit button from submitting a form.
  2. Prevent a link from following the URL.

event.stopPropagation() Method

jQuery event.stopPropagation() method stops the bubbling of an event to parent elements, preventing any parent event handlers from being executed.

return False

It simply stops the execution of the function(). That means, it will end the whole execution of process.

Reason:

The reason to use return false; is that you don't want to execute the function any more in strictly mode .










net-informations.com (C) 2019    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.