Skip to content

Instantly share code, notes, and snippets.

@steveosoule
Last active May 13, 2024 09:34
Show Gist options
  • 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