Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

creating a Scroll To Top button [closed]

I want to create a similar button as in Lenta.ru, with a smooth retractable effect, can you help me with that?

like image 986
BrBa Avatar asked Jun 08 '26 14:06

BrBa


1 Answers

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);
        });
    });
});   
like image 127
yeyene Avatar answered Jun 11 '26 02:06

yeyene