Skip to content

Instantly share code, notes, and snippets.

@imjakechapman
Created July 24, 2012 05:46
Show Gist options
  • Select an option

  • Save imjakechapman/3168260 to your computer and use it in GitHub Desktop.

Select an option

Save imjakechapman/3168260 to your computer and use it in GitHub Desktop.
quick little snippet to use on all of your anchors that are hooked to a Div ID
$(function($){
$('a').on('click', function(e){
var $anchor = $(this).attr("href");
var $hrefStart = $anchor.substr(0, 1);
if ( $hrefStart == "#" ) {
$('html,body').animate({
scrollTop: $($anchor).offset().top
}, 1500, 'easeInOutExpo');
e.preventDefault();
} else {
window.location.href = $anchor;
}
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment