Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript return true or false at the end of the function Re: return true or false at the end of the function

#115996
TheDoc
Member

It’s commonly used on click functions to stop the browser for doing its default behaviour.

For example, if your `.scrolltop` element was an anchor tag, you’d have to put `#` as its `href` which would append the `#` to the URL. That’s not really what we want for the user to experience, so we make it not happen by returning false at the end up the function.

This is not the best practice, though. For more info, this article is good reading: http://fuelyourcoding.com/jquery-events-stop-misusing-return-false/