Javascript smooth scrolling not working in Firefox

I made this website: bosd.eu. It has a javascript / jQuery piece that focuses on the correct area of ​​the page when clicked.

However, when I use Firefox, neither mobile nor desktop work.

So, should this be javascript right?

var initSmoothScroll = function(){
    $('.scroll').click(function () {
        doScroll($(this))
    });
};

var doScroll = function($element){
    $('body').animate({
        scrollTop: $('#' + $element.attr('target')).offset().top - 10
    }, 300);
};

$(window).scroll(function() {
    if ($(window).scrollTop() > 100) {
        $('#topbutton').fadeIn('slow');
    }
    else {
        $('#topbutton').fadeOut('fast');
    }
});

Here's how it is processed in HTML:

<a class="scroll" target="story" id="storybutton"><h1>ABOUT</h1></a>

I found this while searching, but he did not give me an answer:

+4
source share
1 answer

Apparently, I needed to add HTML to body.animate:

var doScroll = function($element){
$('body, html').animate({

Now it works flawlessly.

+2
source

All Articles