Skip to content

zachakbar/smooth-scroll.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Smooth Sroll

smooth scroll for anchors

function smoothScroll() {
    $('a[href*="#"]:not([href="#"])').click(function() {
        if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
            var target = $(this.hash);
            target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
            if (target.length) {
                $('html,body').animate({
                    scrollTop: target.offset().top
                }, 1000);
            return false;
            }
        }
    });
}

$(document).ready(function(){
    smoothScroll();
});

About

Smooth scrolling for anchors

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published