js滑动到页面底部实现

js实现

1、window.scrollTo(0,document.documentElement.clientHeight);  //js

jq实现

2 、var windowHeight = parseInt($("body").css("height"));//jq

      $("#toBottom").click(function () {

           $("html,body").animate({ "scrollTop": windowHeight }, 200);

      });

同理回到顶部js实现只需要改为scrollTo(0,0),jq只需要改为"scrollTop": 0 

posted @ 2020-08-28 17:26  叫我汤先森  阅读(5345)  评论(0)    收藏  举报