<!doctype html><html> <head> <meta charset="utf-8"> <meta name="keywords" content=""> <meta name="description" content=""> <title>study html</title> <script src="js/jquery-3.2.1.min.js" type="text/javascript"></script> <style type="text/css"> div{ width:500px; height:500px; background:green; border:1px solid #f00; } .xa{width:40px;height:40px;background:#000;color:#fff;display:none;position:fixed;} </style> </head> <body> <span class="xa">返回</span> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <script type="text/javascript"> $(window).scroll(function(){ var top=$(this).scrollTop(); if(top>=500){ $(".xa").show(); }else{ $(".xa").hide(); } }); $("span").click(function(){ $("body").animate({scrollTop:0},3000); }); </script> </body></html>
添加回答
举报
0/150
提交
取消