多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
``` function backTop(btnId) { var btn = document.getElementById(btnId); var d = document.documentElement; var b = document.body; window.onscroll = set; btn.style.display = "none"; btn.onclick = function() { btn.style.display = "none"; window.onscroll = null; this.timer = setInterval(function() { d.scrollTop -= Math.ceil((d.scrollTop + b.scrollTop) * 0.1); b.scrollTop -= Math.ceil((d.scrollTop + b.scrollTop) * 0.1); if (d.scrollTop + b.scrollTop == 0) clearInterval(btn.timer, (window.onscroll = set)); }, 10); }; function set() { btn.style.display = d.scrollTop + b.scrollTop > 100 ? "block" : "none"; } } backTop("goTop"); ```