Skip to content

Instantly share code, notes, and snippets.

@dDondero
Last active January 28, 2016 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dDondero/d93fb4d1d9626817fdd1 to your computer and use it in GitHub Desktop.
Save dDondero/d93fb4d1d9626817fdd1 to your computer and use it in GitHub Desktop.
SImple enough. Using jQuery to smooth scroll to certain <div>
jQuery(function(){
function scrollToAnchor(aid){
var aTag = jQuery("a[name='"+ aid +"']");
jQuery('html,body').animate({scrollTop: aTag.offset().top},'slow');
}
jQuery("#menu-item-243").click(function() { // Item to click
scrollToAnchor('kontakt'); // Item to scroll to
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment