Skip to content

Instantly share code, notes, and snippets.

@kohki-shikata
Last active November 28, 2015 13:21
Show Gist options
  • Save kohki-shikata/8aa92e1c68a300a48144 to your computer and use it in GitHub Desktop.
Save kohki-shikata/8aa92e1c68a300a48144 to your computer and use it in GitHub Desktop.
jQuery ToTop button
// 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