Skip to content

Instantly share code, notes, and snippets.

@oterox
Last active May 30, 2019 08:51
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 oterox/cacbb81631082a4907ddff15c6768543 to your computer and use it in GitHub Desktop.
Save oterox/cacbb81631082a4907ddff15c6768543 to your computer and use it in GitHub Desktop.
Scroll anchor jquery
$(window).load(function(){
// Quitamos el # del hash
var hash = location.hash.replace('#','');
//Si hay un hash es que vamos a mostrar un tipo de pista
if(hash != ''){
//Hacemos scroll al id que viene en el hash y le quitamos 50px para que aparezca debajo del menú
$('html, body').animate({ scrollTop: $('#' + hash).offset().top - 50}, 1000);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment