creating a Scroll To Top button
25,748
Check this DEMO http://jsfiddle.net/yeyene/J3zyq/3/
$(document).ready(function() {
$(window).scroll(function() {
if($(this).scrollTop() > 100){
$('#goTop').stop().animate({
top: '20px'
}, 500);
}
else{
$('#goTop').stop().animate({
top: '-100px'
}, 500);
}
});
$('#goTop').click(function() {
$('html, body').stop().animate({
scrollTop: 0
}, 500, function() {
$('#goTop').stop().animate({
top: '-100px'
}, 500);
});
});
});
Author by
Admin
Updated on July 16, 2022Comments
-
Admin almost 2 years
I want to create a similar button as in Lenta.ru, with a smooth retractable effect, can you help me with that?