Hello, first off, I would like to state that I am using this code:
<style>
#myBtn {
width: 50px;
height: 50px;
display: none;
position: fixed;
bottom: 20px;
right: 30px;
z-index: 1;
border: none;
outline: none;
font-size: 25px !important;
color: #17306e;
cursor: pointer;
padding: 10px 10px 10px 11px;
border-radius: 50%;
box-shadow: 1px 1px 5px #000;
// Change the hex code in the next line to change background color
background-color: #cbcccd;
}
#myBtn:hover {
background-color: #aeaeae;
}
</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/js/all.min.js" crossorigin="anonymous"></script>
<button onclick="topFunction()" id="myBtn" title="Go to top">
<i class="fas fa-arrow-up"></i>
</button>
<script>
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
document.getElementById("myBtn").style.display = "block";
} else {
document.getElementById("myBtn").style.display = "none";
}
}
function topFunction() {
$('html,body').animate({ scrollTop: 0 }, 1000);
}
</script>
With that being said, the Jump to Top button only seems to appear once I've hit the bottom of a page. However, after I reach the bottom of the page, the button stays visible as I scroll back up.
So my question is: what code do I need to add/modify to make the Jump to Top button stay visible as soon as you start to scroll down? I don't have a website to share, since my trial has expired.
Thanks!