Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atfornes/023ead03a72b72f4b70b to your computer and use it in GitHub Desktop.
Save atfornes/023ead03a72b72f4b70b to your computer and use it in GitHub Desktop.
Bootstrap Smooth Scroll to Anchor
!function ($) {
$(function(){
// all items with id are possible targets
$('[id]').carousel({});
var $root = $('html, body');
$('a').click(function() {
var href = $.attr(this, 'href');
$root.animate({
scrollTop: $(href).offset().top
}, 500, function () {
window.location.hash = href;
});
return false;
});
})
}(window.jQuery)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment