纯js实现回到锚点
window.requestAnimationFrame = window.requestAnimationFrame || function (fn) { return setTimeout(fn, 1000 / 60); }; var target = document.getElementById("plist").offsetTop; if (location.href.indexOf('#plist') > 0 && parseInt(target) > 0) { (function animation() { var init = 0; (function fn() { init += 40; if (init >= target) { init = target; } else { requestAnimationFrame(fn); } document.body.scrollTop = document.documentElement.scrollTop = init; })(); })(); }