Skip to content

Instantly share code, notes, and snippets.

@ElmahdiMahmoud
Last active October 12, 2015 18:47
Show Gist options
  • Save ElmahdiMahmoud/4070774 to your computer and use it in GitHub Desktop.
Save ElmahdiMahmoud/4070774 to your computer and use it in GitHub Desktop.
jquery: Scroll top top
<!-- Backto top html -->
<div class="totop"><a href="#top"></a></div>
/* back to top css */
.totop a {
position: fixed;
right: 5%;
bottom: 10%;
display: none;
background: ;
width: 30px;
height: 31px; }
/* back to top js */
$('a[href=#top]').click(function(){
$('body,html,document').animate({scrollTop: 0},600);
return false;
});
$(window).scroll(function(){
if ($(this).scrollTop() > 50) {
$('.totop a').fadeIn();
} else {
$('.totop a').fadeOut();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment