Jquery event handlers return values
Is there any use to return values from .click()
and .change()
handlers (like return true
or return false
)?
return false;
will stop the event from bubbling up AND suppress the default action.
In otherwords, returning false is analogous to these two lines
event.stopPropagation();
event.preventDefault();
For events that bubble and are cancelable, at least.
return false
in such a handler results in event.stopPropagation()
(only for jQuery event handlers, as Tim Down suggested in the comments) and event.preventDefault()
being called automatically by jQuery.
return true
is the same as returning nothing (no action is taken by jQuery).