1. 程式人生 > >獲取錨點、底部返回

獲取錨點、底部返回

1.通過錨點獲取對應的位置 function sclTo(deId) {//滑動到特定位置; let h = ((`{deId}`).offset().top; $(‘body,html’).animate({ scrollTop: h }) }; 2.滾動條持續上升 var inp = document.getElementsByClassName(“fanhui”)[0]; var mc = null; inp.onclick = function() { mc = setInterval(function() { document.documentElement.scrollTop -= 50; if(document.documentElement.scrollTop <= 0) { // document.documentElement.scrollTop = 0; clearInterval(mc); } }, 10) }