2017-04-21 100 views
0

我有功能scrollTop的麻烦。我尝试设置滚动到#COMMENT时.scrollToComment是点击的,但不知道为什么它不工作...scrollTop jQuery不工作:/

头:

<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/

请帮助。

回答

1

替换代码为滚动

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

它做工精细,我

干杯