Skip to content

How to make scroll button disappear when scrolled to bottom

I made a scrollable with a floating button inside, which makes it scroll to bottom when clicked,

box {
padding: 8px 20px;
border: 1px solid #222;
position: sticky;
box-shadow: -3px 3px 3px #999;

<div id="utt" style="overflow-y: scroll; height:75%;">

<a href="#" onclick="scroll" class="toBotetom"><box><b>Scroll to bottom</b></box></a>

<script src=""></script>
  $(document).ready(function scroll() {
    $("a.toBotetom").click(function scroll() {
    let elm = $("#utt")
        scrollTop: elm[0].scrollHeight
      }, 500);

How can I make this button disappear when the is completely scrolled to the bottom?



Heading ##add this html:

<button id="scrollDown" onclick="bottom()">Scroll to bottom</button>

Then add this to Javascript:

var mybutton = document.getElementById("scrollDown");
window.onscroll = function() {scrollFunction()};

function bottom() {
  if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { = "block";
  } else { = "none";

// When the user clicks on the button, scroll to the bottom of the document
function bottom() {
  document.body.scrollTop = 0;
  document.documentElement.scrollTop = 5555550;

Now for the CSS:

#scrollDown {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 30px;
  z-index: 99;
  font-size: 18px;
  border: none;
  outline: none;
  background-color: red;
  color: white;
  cursor: pointer;
  padding: 15px;
  border-radius: 4px;
User contributions licensed under: CC BY-SA
8 People found this is helpful