Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.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 滚动动画工作不正常;当我点击链接时,我得到了指示,但没有动画_Javascript_Jquery_Html_Animation_Jquery Animate - Fatal编程技术网

Javascript 滚动动画工作不正常;当我点击链接时,我得到了指示,但没有动画

Javascript 滚动动画工作不正常;当我点击链接时,我得到了指示,但没有动画,javascript,jquery,html,animation,jquery-animate,Javascript,Jquery,Html,Animation,Jquery Animate,平滑滚动不起作用??当我单击链接滚动到某个元素/部分时,它会直接将我带到该元素/部分,即使将动画速度更改为5000,也不会平滑滚动。我的脚本是正确的,所以我不知道该怎么做 这是我下面的代码;对于查询,我已经用“#”标记正确地标记了我的链接,并为我的每个元素正确地创建了一个ID $(function() { $('a[href*="#"]:not([href="#"])').click(function() { if (location.pathname.replace(/^\

平滑滚动不起作用??当我单击链接滚动到某个元素/部分时,它会直接将我带到该元素/部分,即使将动画速度更改为5000,也不会平滑滚动。我的脚本是正确的,所以我不知道该怎么做

这是我下面的代码;对于查询,我已经用“#”标记正确地标记了我的链接,并为我的每个元素正确地创建了一个ID

    $(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
        }, 5000);
        return false;
      }
    }
  });
});
 $(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;
}}
});
});