Skip to content

Instantly share code, notes, and snippets.

@jessebeach
Created April 16, 2013 23:55
Show Gist options
  • Select an option

  • Save jessebeach/5400660 to your computer and use it in GitHub Desktop.

Select an option

Save jessebeach/5400660 to your computer and use it in GitHub Desktop.
A simple scroll to behavior using the jQuery.scrollTo plugin.
(function ($) {
$(function () {
var $links = $('a[href^="#"]');
$links
.on('click', function (event) {
var $this = $(this);
var href = $this.attr('href');
$.scrollTo(href, {
duration: 500,
onAfter: function () {
location.replace(href);
},
});
event.preventDefault();
});
});
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment