This is about how to create a "scroll to top" button that becomes visible
when the user starts to scroll the page.
<script src='https://code.jquery.com/jquery-3.5.0.js' type='text/javascript'></script>
<script>
$(document).ready(function(){
//add scroll top button
$("body").append('');
// Get the button
let mybutton = document.getElementById("hdo-scroll-top-button");
// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}
// When the user clicks on the button, scroll to the top of the document
$("#hdo-scroll-top-button").click(function(){
$("html, body").animate({ scrollTop: "0" });
});
});
</script>
</body>
</html>