<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.divH {
height: 1800px;
}
.divT {
width: 50px;
height: 50px;
font-size: 23px;
background-color: #2F4F4F;
color: white;
position: fixed;
right: 18px;
bottom: 18px;
}
.divT:hover{
cursor: pointer;
}
.hide {
display: none;
}
</style>
</head>
<body>
<div></div>
<div class="divT hide" onclick="ReturnTop();"><strong>返回顶部</strong></div>
<script src="../../jquery-1.12.4.js"></script>
<script>
window.onscroll = function () {
var current = $(window).scrollTop();
if (current > 180){
$(".divT").removeClass("hide");
}else {
$(".divT").addClass("hide");
}
};
function ReturnTop() {
$(window).scrollTop(0);
}
</script>
</body>
</html>
人生没有十全十美的东西,没有十全十美的人,关键是清楚到底想要什么。得到想要的,肯定会失去另外一部分。如果什么都想要,只会什么都得不到。