Page scrolling error on button click jQuery

I want to scroll page to second section on a button click. I am using following jquery

$('.home_scroll_btn a').on('click', function(){
        var scrollPosition = $('#intro-home').offset().top;
        $('html, body').animate({

The problem is when i click the button the page first scroll to top and then scroll to particular section.

Thanks in advance!

Answers 1

  • If .home_scroll_btn a has href="#" or something like that, it will scroll up to the top. If it does have one, add e.preventDefault() or return false on the function.

Related Articles