Javascript jQuery平滑滚动以定位不工作
我以前使用过平滑滚动,没有任何问题,因为我不确定这次是什么阻止了它工作。我没有在控制台中得到任何与平滑滚动有关的错误。网站网址为: 以及平滑滚动的当前代码:Javascript jQuery平滑滚动以定位不工作,javascript,jquery,html,Javascript,Jquery,Html,我以前使用过平滑滚动,没有任何问题,因为我不确定这次是什么阻止了它工作。我没有在控制台中得到任何与平滑滚动有关的错误。网站网址为: 以及平滑滚动的当前代码: jQuery(document).ready(function($){ $('a[href*=#]:not([href=#])').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') &&am
jQuery(document).ready(function($){
$('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({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
如果有人对什么可以阻止这一点有任何建议,那就太好了。我在控制台中看到至少一个错误“showLeft未定义”。我建议修正一下,看看是否有帮助。@yuyokk我已经修正了那个错误,还有其他想法吗?谢谢-本