Jump to content

Why is Squarespace changing anchor target upon reload and jumping to top?

Recommended Posts

Am a coding newbie. I have a web site of Squarespace 7.0 and want to show / hide an embedded code when the site visitor clicks a button.

To accomplish that I've included a button having a link targeting to "#show-more". Code injection to header of page binds this to a function that toggles visibility of the block.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script>
$(document).ready(function(){  
  // Load More
  $('a[href="#load-more"]').click(function(){
    $("#block-yui_3_17_2_1_1726217207010_54845").toggleClass("show");
    }
  );
});
</script>

 

Toggling visibility works as intended, but while reloading the squarespace site replaces the given anchor with a different anchor target and reloads to top of the page. The user will need to scroll down again and will likely feel annoyed.

I would like the user to stay on the same area of the site. Any suggestion how to fix this? 

 

Link to comment
  • Replies 1
  • Views 503
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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.