xxxxxxxxxx
1
<section id="topSection" class="blue"></section>
2
<section class="red"></section>
3
<section class="yellow"></section>
4
<section class="green"></section>
5
6
<div id="btnTop" class="fixed-action-btn smooth-scroll" style="bottom: 45px; right: 24px;display: none;">
7
<a href="#topSection" class="btn-floating btn-large red">
8
<i class="fa fa-arrow-up"></i>
9
</a>
10
</div>
xxxxxxxxxx
1
section {
2
min-height:100vh;
3
}
xxxxxxxxxx
1
$(function() {
2
3
var $btn = $('#btnTop');
4
var $home = $('#topSection');
5
var startpoint = $home.scrollTop() + $home.height();
6
7
$(window).on('scroll', function() {
8
if($(window).scrollTop() > startpoint) {
9
$btn.show();
10
} else {
11
$btn.hide();
12
}
13
});
14
});
Console errors: 0