Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.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应用溢出值后scrollTop()不工作?_Javascript_Jquery_Html_Css_Scroll - Fatal编程技术网

Javascript 使用jQuery应用溢出值后scrollTop()不工作?

Javascript 使用jQuery应用溢出值后scrollTop()不工作?,javascript,jquery,html,css,scroll,Javascript,Jquery,Html,Css,Scroll,我正在使用Chris Coyier的插件(实际上,它是Devin Sturgeon的一个修改版本)来设置滚动到锚定链接的动画: // Easing for links pointing to anchors $(document).ready(function() { $('a[href*=#]:not([href=#])').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.rep

我正在使用Chris Coyier的插件(实际上,它是Devin Sturgeon的一个修改版本)来设置滚动到锚定链接的动画:

// Easing for links pointing to anchors
$(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;
      }
    }
  });
});
在我将溢出值应用于jQuery之前,它工作得非常好。例如,在我关闭一个模式窗口后,这段代码负责隐藏水平溢出并将垂直溢出设置为自动:

$('.file-content a.close-reveal-modal').on('click', function() {
  $('html, body').css({
    'overflow-y' : 'auto',
    'overflow-x' : 'hidden'
  });
});
应用这些值后,用于动画滚动到锚定链接的插件停止工作,单击它们不会产生任何结果。如果我在关闭一个模式时删除了负责设置溢出的代码,Chris的插件每次都会像一个符咒一样工作

为什么会这样


任何形式的帮助都将不胜感激

我不知道这是否能帮到你,但我发现了一个提示:

您试过调试它吗?

因为我怀疑在你的例子中
target.offset().top
您可能想知道,Beri,Stackoverflow Netiquette不鼓励使用URL链接删除程序化帖子。而是在你的文章中包含优点,一旦被引用的页面不需要永远保持不变,以便仍然提供你想要的内容。您可能希望重新阅读StackOverflow Do-s和NOT-s,并重新编辑您的帖子,以显示您遵守社区网络礼仪的意愿,同时避免任何版主采取任何可能认为有必要执行上述规则的不利步骤。享受你决定加入的有贡献的成员的伟大社区。你明白了吗?