Last active
October 12, 2015 18:47
-
-
Save ElmahdiMahmoud/4070774 to your computer and use it in GitHub Desktop.
jquery: Scroll top top
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
<!-- 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