Jquery Event Handlers Return Values
Is There Any Use to Return Values From. Click() And. Change() Handlers (Like Return True or Return False)? 2 2 Answers Return False; Will Stop the Event from...
Is there any use to return values from .click() and .change() handlers (like return true or return false)?
2 Answers
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).