Use JavaScript events correctly

JavaScript Events, or stop misusing return false:

The main reason return false is so widely misused is because it appears to be doing what we want. Link callbacks no longer redirect the browser, form submit callbacks no longer submit the form, etc. So why is it so bad?

First off, return false is actually doing three very separate things when you call it:

  • event.preventDefault();
  • event.stopPropagation();
  • Stops callback execution and returns immediately when called.

“Wait a minute,” you cry! I only needed to stop the default behavior! I don’t need these other two items… I think.

Very good introduction to JS event handling.