标签:function log event lock list window div otto play
1 <body> 2 <div style="height: 2000px;"></div> 3 <a href="#" id="backTop" style="display: none;position: fixed;bottom: 0;right: 0;">回到顶部</a> 4 <script> 5 window.addEventListener(‘scroll‘, function () { 6 var backTop = document.getElementById(‘backTop‘); 7 if (document.body.scrollTop > 200) { 8 backTop.style.display = ‘block‘; 9 } else { 10 backTop.style.display = ‘none‘; 11 } 12 }) 13 </script> 14 </body>
为页面增加滚动事件侦听,当页面滚动高度大于200,在页面右下方出现 返回顶部 按钮
标签:function log event lock list window div otto play
原文地址:http://www.cnblogs.com/jiaoyue/p/6765465.html