JQUERY,scrollTo,向下滚动后,页面不会让我向上滚动一秒…… Y?

我正在使用以下JQUERY将偶数附加到标题中的链接,该链接基本上滚动到页面的底部:

$('#comment-count-btn').click(function(){ $('html,body').scrollTo('#comment-wrapper', 500); }); 

问题是,它一直滚动到页面的底部(这是正确的),但是当我尝试向上滚动时,滚动条会跳跃,好像它被锁定了一点点。

有任何想法吗?

尝试添加return false; 在click()函数的最后。 此外,尝试scrollTo只到’body’而不是html和body。 它可能会让scrollTo感到困惑。

尝试使用console.log跟踪您的点击,很可能您的元素被多次点击。

此外,如果您有滚动捕获位置,请确保点击时在滚动之外。 这就是我修复同样问题的方法。

 $(window).on('scroll', function()){ if (scrollTop.length > 0) { if ($(this).scrollTop() > 500) { scrollTop.fadeIn(); } else { scrollTop.fadeOut(); } } } // the click event has to be outside of the scroll event scrollTopButton.click(function() { $("html,body").animate({ scrollTop: 0 }, 1000); return false; }); 

滚动function中的click事件对我有用