I have the below jQuery code, I want the scroll to animation to work when on the same page and when you click on another page.
At the moment I have the following:-
jQuery('a[href^="#"]').on('click',function (e) {
e.preventDefault();
var target = this.hash;
var jtarget = jQuery(target);
jQuery('html, body').stop().animate({
'scrollTop': jtarget.offset().top
}, 900, 'swing', function () {
window.location.hash = target;
});
});
It is going to the section but no animation is happening.
Any help would be much appreciated!