Difference Between Event.PreventDefault() And Return False




We use these events in the following situation. When we needs to prevent the event handlers from executing after a certain event is fired. The following is the code for both event.preventDefault() and "return false".

Difference Between Event.PreventDefault() And Return False, Event.PreventDefault() vs Return False, Event.PreventDefault(), Return False, e.stopPropagation(), event.stopPropagation(), e.PreventDefault(), Asp.Net, MVC, Jquery

Difference Between Event.PreventDefault() And Return False, Event.PreventDefault() vs Return False, Event.PreventDefault(), Return False, e.stopPropagation(), event.stopPropagation(), e.PreventDefault(), Asp.Net, MVC, Jquery




return false do the action of both e.preventDefault() and e.stopPropagation(). e.preventDefault() would prevent the default event from occuring. e.stopPropagation() would prevent the event from bubbling up. e.stopPropagation() would prevent any parent handlers from being notified of the event. But return false would do the functions of both e.preventDefault() and e.stopPropagation() . The following code describes how e.stopPropagation() is invoked.

Difference Between Event.PreventDefault() And Return False, Event.PreventDefault() vs Return False, Event.PreventDefault(), Return False, e.stopPropagation(), event.stopPropagation(), e.PreventDefault(), Asp.Net, MVC, Jquery