jQuery scrollTop() method not working

前端 未结 4 2463
花落未央
花落未央 2021-02-19 19:53

I have the following jQuery code

$(document).ready(function () {
    $(\'.navtoTop\').click(function(){
           $(\"html\").scrollTop( $(\"#topofthePage\").of         


        
4条回答
  •  不要未来只要你来
    2021-02-19 20:42

    You have to use window instead of html:

    $(window).scrollTop( $("#topofthePage").offset().top );
    

    Note that window should not be enclosed in quotes as i'ts an object and not a tag.

提交回复
热议问题