Last active
November 28, 2015 13:21
-
-
Save kohki-shikata/8aa92e1c68a300a48144 to your computer and use it in GitHub Desktop.
jQuery ToTop button
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
// this script depends on jQuery | |
$('#toTop').click(function(){ | |
var speed = 400; | |
var href= $(this).attr("href"); | |
var target = $(href == "#" || href == "" ? 'html' : href); | |
var position = target.offset().top; | |
$("html, body").animate({scrollTop:position}, speed, "swing"); | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment