console
/*
function Btn(){
var Height=Math.floor($(window).height());
var scrollTop=Math.floor($(document).scrollTop());
var maxScroll=Math.floor($(document).height())-clientHeight;
if(scrollTop>clientHeight)
$('#btn').fadeIn(500);
else
$('#btn').fadeOut(500);
if(scrollTop>maxScroll)
$('#btn').hide(500);
else
$('#btn').show(500);
}
//返回顶部
function returnTop(){
$body.animate({scrollTop: 0},400);
}
//返回底部
function returnBottom(){
$body.animate({scrollTop: $(document).height()},400);
}
*/
$(document).ready(function () {
$(window).scroll(function () {
if ($(this).scrollTop() > 200) {
$('#btn').fadeIn(500);
} else {
$('#btn').fadeOut(500);
}
});
// scroll body to 0px on click
$('#btn').click(function () {
$('body,html').animate({
scrollTop: 0
}, 500);
return false;
});
});
<div class="contain">
<h1>Top</h1>
<h1 class="footer">Footer</h1>
<div id="btn">goto</div>
</div>
.contain{
height:2000px;
}
.footer{
position:absolute;
margin-bottom:10px;
bottom:10px;
}
#btn{
position: fixed;
bottom: 50px;
right: 10px;
background:#eee no-repeat;
display: none;
font-weight:bold;
color:#e81919;
height:40px;
width:50px;
cursor: pointer;
}