How can I create a bottom to top button?

Hello

Please tell me How can I create the button bottom to top.

Hi @jaygupta-tech
Just put this code before body closing tag


      
  
    
  
    
    
    

Thanks!

Hi @jaygupta-tech , this is Landry from Avantify app

  1. Go to Online Store → Click edit code button
  2. Find theme.liquid file → add the following code just bellow tag

#toTopBtn {
  display: none; 
  position: fixed;
  bottom: 20px; 
  right: 30px; 
  z-index: 99; 
  border: none; 
  outline: none;
  background-color: red; 
  color: white; 
  cursor: pointer; 
  padding: 15px; 
  border-radius: 10px;
}

#toTopBtn:hover {
  background-color: #555; 
}

window.onscroll = function() {scrollFunction()};

function scrollFunction() {
  if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
    document.getElementById("toTopBtn").style.display = "block";
  } else {
    document.getElementById("toTopBtn").style.display = "none";
  }
}

function topFunction() {
  document.body.scrollTop = 0; 
  document.documentElement.scrollTop = 0; 
}