Smooth scrolling for internal links to anchors in the same page with jQuery
Javascript
/*
* Smooth scrolling for any links that point to an anchor (e.g. <a href="#anchor">)
*/
$("a[href^='#']").on("click", function(e) {
e.preventDefault();
// Offset: use this only if you have (for example) a fixed header
var offset = $("#fixed-header").height();
return $("html, body").animate({
scrollTop: $(this.hash).offset().top - offset
}, 300);
});
-
Madi