Quizá esto te sirva:
http://jsfiddle.net/1ce711b0/
Código CSS:
Ver original.arriba {
position:fixed;
background:red;
color:white;
opacity:0;
}
Código Javascript
:
Ver original// SCROLLTESTER START //
$('<h1 id="st" style="position: fixed; right: 25px; bottom: 25px;"></h1>').insertAfter('body');
$(window).scroll(function () {
var st = $(window).scrollTop();
var scrollBottom = $(document).height() - $(window).height() - $(window).scrollTop();
$('#st').replaceWith('<h1 id="st" style="position: fixed; right: 25px; bottom: 25px;">scrollTop: ' + st + '<br>scrollBottom: ' + scrollBottom + '</h1>');
});
// SCROLLTESTER END //
$(window).scroll(function(){
var scrollBottom = $(document).height() - $(window).height() - $(window).scrollTop();
if (scrollBottom < 200) {
$('.arriba').css("opacity","1");
} else {
$('.arriba').css("opacity","0");
}
});
$('.arriba').click(function(){
$("html, body").animate({ scrollTop: 0 }, 700);
return false;
});