Skip to content

Instantly share code, notes, and snippets.

@ivolivares
Last active December 17, 2015 00:10
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 ivolivares/5519268 to your computer and use it in GitHub Desktop.
Save ivolivares/5519268 to your computer and use it in GitHub Desktop.
Un simple "Page Scroller" en 146 bytes de Javascript. | A simple "Page Scroller" in 146 bytes of Javascript.
$("a[data-go]").on("click",function(event){
var elem = $("#" + $(this).attr("data-go"));
$('html, body').animate({
scrollTop: elem.offset().top
}, 'slow');
event.preventDefault();
});
/*
*
* Como utilizar:
* <a href="Vínculo" data-go="ID_Destino">to o lo que sea</a>
* <div id="ID_Destino">lo que sea</div>
*
* How to use:
* <a href="Link" data-go="Destiny_ID">Text</a>
* <div id="Destiny_ID">whatever</div>
*
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment