Write a listener’s body on four real pages (a link, a form, a checkbox, a dropdown) and click: the board separates the browser’s default action from the…
Get them wrong and the form still reloads (no preventDefault), or click-outside, analytics and delegation die quietly (too much stopPropagation). Once you see them as two separate things, this whole class of bugs goes away.
Two brakes that do not touch each other
preventDefault on a form submit The page reloads and the input is gone. Call e.preventDefault() in the submit listener (not on the button’s click, so Enter is caught too), then send with fetch.stopPropagation It kills every listener above: click-outside to close a menu, analytics, delegation. Let the parent check e.target.closest(…) when it must ignore some clicks.return false Two separate things. return false only cancels in a property handler (onclick) and in jQuery; addEventListener ignores it. Call the method itself.preventDefault on a checkbox, the box will not tick Ticking is the click’s default action. If all you want is the parent row not to open, use stopPropagation().e.preventDefault(), click again The page stays, yet the card and document still get the click.e.stopPropagation() alone The other way round: the card and document get nothing, yet the link still navigates.return false in addEventListener Its return value is ignored: the link still navigates. Switch to onclick and see the difference.