Jump to content

Hide "back to top" button on mobile and on desktop home page

Recommended Posts

Hello! I know this question has been asked before but the solution isn't working for me when I try to implement it. It may have to do with the way my code is set up. Since my template and version of Squarespace doesn't have a native "back to top" button, I found code from an outside source instead and injected into the footer and css advanced sections. The result is great on the pages that need the button, but I want to remove it from all mobile and also from desktop home page. The name of my theme is: ORCHID-STURGEON-6MXD.SQUARESPACE.COM

Please advise on how I can do this. Thank you!


<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>

   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);


I added this code to DESIGN → CUSTOM CSS section:

#myBtn {
   width: 50px;
   height: 50px;
   display: none;
   position: fixed;
   bottom: 20px;
   right: 30px;
   z-index: 99;
   border: none;
   outline: none;
   font-size: 25px !important;
   color: white;
   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: #a4a4a4;

#myBtn:hover {
   background-color: #aeaeae;

Edited by idreamofjeannie
Link to comment
  • idreamofjeannie changed the title to Hide "back to top" button on mobile and on desktop home page
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Add to Design > Custom CSS

/* Hide back to top mobile */
@media screen and (max-width:767px) {
#myBtn {display: none !important;}


Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.