window.location.hash . , :
var navigationFn = {
goToSection: function(id) {
$('html, body').animate({
scrollTop: $(id).offset().top
}, 0);
}
}
( someID - , ):
navigationFn.goToSection('#someID');
With this, you can also change the speed of the animation (I have it at 0), so that it is instantaneous, but you can pass the value of the function so that the code is reused.
source
share