Search code examples
javascriptjqueryscrollscrollto

jQuery ScrollTo plugin does not scroll to the element on Firefox


I'm using the scrollTo plugin by Ariel Flesler to scroll to an element. However this piece of code just doesn't run on Firefox (v 61).

$(document).ready(function(){
    $('html, body').scrollTo(document.getElementById('login-link'), 800);
});

Here's a demo: https://jsfiddle.net/1n26s3dm/1/

Any idea what am I doing wrong?


Solution

  • Add the following code and make sure you have jQuery installed, because on your fiddle there isn't jquery

     $('html, body').animate({
                scrollTop: $("#login-link").offset().top
            }, 800, function(){
    
            // this is the callback after the animation is done
            // you can emit events here
            $("#login-link").trigger('click');
    
    });