Last active
December 17, 2015 00:10
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("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