-
-
Save zdimaz/fefdb244603405749eec48a9d5059028 to your computer and use it in GitHub Desktop.
btn to top scroll
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
js | |
$(window).on("scroll", function(){ | |
if ($(this).scrollTop() > 100) { | |
$('.btn_scrollup').fadeIn(); | |
} else { | |
$('.btn_scrollup').fadeOut(); | |
} | |
}); | |
$('.btn_scrollup').on('click', function(){ | |
$("html, body").animate({ scrollTop: 0 }, 600); | |
return false; | |
}); | |
HTML | |
<a href="#" class="btn_scrollup">Scroll</a> | |
CSS | |
.btn_scrollup{ | |
width:40px; | |
height:40px; | |
opacity:0.3; | |
position:fixed; | |
bottom:50px; | |
right:80px; | |
display:none; | |
text-indent:-9999px; | |
background-color: red; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment