The following script is working live for 2 times. The third time i click on a a with a hash it does not work any more and the following error shows up in the Console. Any ideas?
TypeError: 'undefined' is not a function (evaluating 'n.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration)')
My Code:
$('a[href*=#]:not([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) {
$('html,body').animate({
scrollTo: target.offset().top
}, 500);
return false;
}
} });
$(window).scroll(function() {
if ($(this).scrollTop() > 220) {
$('.backtotop').fadeIn(200);
} else {
$('.backtotop').fadeOut(200);
}});
Code from the html:
<a href="#link">LINK</a>
<div id="link">TARGET</div>
Thanks a lot!