jQuery scrollTop() method not working

前端 未结 4 2464
花落未央
花落未央 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:20

    Better way to use:

    $(document).ready(function () {
        $('.navtoTop').click(function(){
              $(window).scrollTop()
              $("window").scrollTop( $("#topofthePage").offset().top );
        }); 
    });
    

提交回复
热议问题