I'm facing an issue with a JQuery
function that is supposed to enable smooth scrolling using JQuery
easing, but for some reason, it's not functioning correctly and I'm unable to pinpoint the error.
Here is the code for the function:
$(function(){
$('a[href*=#]').click(function() {
if (location.pathname.replace(/^\//,”) == this.pathname.replace(/^\//,”) && location.hostname == this.hostname) {
var $target = $(this.hash);
$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
if ($target.length) {
var targetOffset = $target.offset().top;
$(‘html,body’).animate({scrollTop: targetOffset}, {duration:1600,easing:'easeInBounce'});
return false;
}
}
});
});
I created a demonstration of this function on JSFiddle. (I also included the code for the JQuery
easing)
Additionally, here's a similar function on JSFiddle. Although this one works, it lacks the option to use easing. Any assistance in resolving this issue would be greatly appreciated.
Edit
To further elaborate on the problem, when the links are clicked, there is no animation - it simply jumps instantly to that section of the page.