Skip to content

Instantly share code, notes, and snippets.

@aziz
Created June 10, 2011 08:07
Show Gist options
  • Save aziz/1018435 to your computer and use it in GitHub Desktop.
Save aziz/1018435 to your computer and use it in GitHub Desktop.
Soft-scroll to an anchor with jQuery
$('a[href^="#"][data-animate]').live('click', function() {
var hash = $(this).attr('href');
var offset = $(hash).offset();
if (offset) {
$('html, body').animate({ scrollTop: offset.top }, 'slow');
location.hash = hash;
return false;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment