Skip to content

Instantly share code, notes, and snippets.

@steveosoule
Last active June 5, 2018 00:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steveosoule/4455944 to your computer and use it in GitHub Desktop.
Save steveosoule/4455944 to your computer and use it in GitHub Desktop.
Simple Scroll To Anchor
// Found at: http://jsfiddle.net/BjpWB/4
function scrollToAnchor(aid){
var aTag = $("a[name='"+ aid +"']");
$('html,body').animate({scrollTop: aTag.offset().top},'slow');
}
scrollToAnchor('id3');
function scrollTo($element){
$('html,body').animate({scrollTop: $element.offset().top},'slow');
}
scrollTo($('#something'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment