前言:
使用原生js实现简单的回到顶部效果。需求比较明确:1.显示与隐藏按钮。2.中途再次触发onscroll清除定时器(暂时未实现,希望各位赐教)
代码:
<!--
Time:2016.8.4
author:Joel
Dom操作
1.document.getElementById 根据ID获取标签元素
2.document.documentElement.scrollTop .ie滚动条数值
3.document.body.scrollTop .chrome
4.document.documentElement.clientHeight 可视区域高度
事件运用
1.window.onload 加载完毕触发事件
2.onclick 点击触发事件
3.window.scroll 滚动条触发事件
定时器
1.setInterval()
2.clearInterval()
-->
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style