【问题标题】:scrollTop jQuery not working :/scrollTop jQuery 不工作:/
【发布时间】:2017-04-21 00:53:43
【问题描述】:

我在使用 scrollTop 功能时遇到了问题。当单击 .scrollToComment 时,我尝试将滚动设置为 #comment,但不知道为什么它不起作用...

头:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js?ver=3.2.1"></script>

和滚动代码:

$(".scrollToComment").click(function() {
$('html, body').animate({
scrollTop: $("#comment").offset().top
}, 2000);
});

问题在于我开始新的小项目: http://katalogliquidow.mrqzi.webd.pl/

请帮忙。

【问题讨论】:

    标签: jquery scrolltop


    【解决方案1】:

    替换滚动代码

    <script>
        $(document).on('click','.scrollToComment',function(){
            $('html, body').animate({
                scrollTop: $("#comment").offset().top
            }, 2000);
        });
    </script>
    

    对我来说很好用

    干杯

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-19
      • 2011-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多