Created
April 29, 2015 04:27
-
-
Save jamenlyndon/d6fd09110397fb26745f to your computer and use it in GitHub Desktop.
Scroll to anchors (jQuery)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Scroll to anchors | |
$(document).ready(function() { | |
$("a[href^=#]").click(function(e) { | |
e.preventDefault(); | |
var dest = $(this).attr('href').replace('#', ''); | |
$('html,body').animate({ scrollTop: $('[name='+dest+']').offset().top }, 'slow'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment