I kinda remade it but here is a simple version:
JQuery:
Code:
$(function(){
scrollup({
id: 'autoup',
image: 'up.png',
display: 100,
fadeduration: [300, 300, 300] //fade in, fade out, scroll time
})
})
function scrollup(a){
var html = '<div id="'+a.id+'"><img src="'+a.image+'" \/></div>'
$(html).appendTo('body');
$(document).on('scroll',window, function(){
if($(this).scrollTop() >= a.display)
$('#'+a.id).fadeIn(a.fadeduration[0]);
else
$('#'+a.id).fadeOut(a.fadeduration[1]);
})
$(document).on('click','#'+a.id,function(){
$("body,html").animate({scrollTop: 0}, a.fadeduration[2]);
})
}
CSS:
Code:
#autoup { position:fixed; right:10px; bottom:5px; cursor:pointer; display:none;}
Updated and you still do not need anything in the body.
Please notice that the id in the scrollup function matches the id in the css
Bookmarks