1
I have the following question. I created a simple button to go back to the top of the page:
<a href="page-top" class="back-to-top">Back to Top</a>
<script>
$(document).ready(function(){
var btt = $('.back-to-top');
btt.on('click', function(e){
$('html, body').animate({
scrollTop:0
}, 500);
e.preventDefault();
});
$(window).on('scroll', function(){
var self = $(this),
height = self.height(),
top = self.scrollTop();
if(top > height){
if(!btt.is('#page-top:visible')){
btt.fadeIn();
}
} else{
btt.hide();
}
});
});
</script>
However I would like to apply the same effect as the facebook button for mobile, where the button will only appear when I scroll up. It’s like?
Welcome to Stackoverflow in Portuguese, this sounds more like a comment than an answer, if you don’t have enough points to comment, try to answer some more "concrete" questions and earn points for example. Once you have points you can comment.
– Guilherme Nascimento