Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery平滑滚动以定位不工作_Javascript_Jquery_Html - Fatal编程技术网

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我已经修正了那个错误,还有其他想法吗?谢谢-本