Lego2012
12/13/2016 - 2:45 PM

Smooth scrolling when clicking on a hash link

Smooth scrolling when clicking on a hash link

<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.

// Smooth scrolling when clicking on a hash link
    $('a[href^="#"]').on('click',function (e) {
        e.preventDefault();

        var target = this.hash;
        var $target = $(target);

        $('html, body').stop().animate({
            'scrollTop': $target.offset().top
        }, 900, 'swing');
    });