</div>
<button>返回顶部</button>
<script type="text/javascript">
var obtn=document.getElementsByTagName("button")[0];
var t=document.documentElement.scrollTop || document.body.scrollTop;
obtn.onclick=function(){
speed=30;
time=setInterval(function(){
document.documentElement.scrollTop-=speed;
if (document.documentElement.scrollTop<500) {
speed=10;
}
if (document.documentElement.scrollTop<=0) {
clearInterval(time);
}
},10)
}
</script>
</body>
简易返回顶部按钮
最新推荐文章于 2024-07-31 16:16:55 发布