smooth scroll

Simple smooth scrolling with jQuery

Just a quick tip, simple smooth scrolling with jQuery. All you need to do is add the class of smooth-scroll to your links, set the link href to the target id, eg. #about and then just add the id to the target container, eg. id=”about”

    // Add smooth-scroll class to your links
    $('.smooth-scroll').on('click', function(e) {

        // Get href of link
        var scrollTarget = $(this).attr('href');

        // Get target position from top of the page
        var targetPosition = $(scrollTarget).offset().top;

        $('html,body').animate({scrollTop: targetPosition}, 800);


Leave a Comment