Skip to content

Instantly share code, notes, and snippets.

@kovaldn
Created July 18, 2013 13:02
Show Gist options
  • Save kovaldn/6029109 to your computer and use it in GitHub Desktop.
Save kovaldn/6029109 to your computer and use it in GitHub Desktop.
Javascript: scroll up button.js
// scroll up-------------------------------------
$(window).scroll(function(){
if ($(this).scrollTop() > 100) {
$('.scrollup').fadeIn();
} else {
$('.scrollup').fadeOut();
}
});
$('.scrollup').click(function(){
$("html, body").animate({ scrollTop: 0 }, 600);
return false;
});
// -----------------------------------------------
// HTML
// <a href="#" class="scrollup">Scroll</a>
// CSS
// .scrollup{
// width:40px;
// height:40px;
// opacity:0.3;
// position:fixed;
// bottom:50px;
// right:80px;
// display:none;
// text-indent:-9999px;
// background: url(../images/icon_top.png) no-repeat;
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment