Home › Forums › JavaScript › return true or false at the end of the function › Re: return true or false at the end of the function
November 29, 2012 at 10:22 pm
#115996
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/