How to make Squarespace list items clickable

This tutorial will show you how to make your Squarespace list item clickable. Currently, you can only click on the 'Call To Action' button to access the page, you cannot click on the image, title or text to reach the page.

Complexity: Easy


Step 1

Create your List Item, with the button links.

Item list

Step 2

Then, simply add the following JavaScript below to Settings > Advanced > Code Injection > Footer and then save your changes..

<!--- Make Squarespace list items clickable on Squarespace 7.1 --->
<!--- Copyright Primitius Consultancy [https://primitusconsultancy.co.uk] --->
<script>

(function() {
    window.addEventListener('DOMContentLoaded', pcLinkItems);

    function pcLinkItems() {

      let pcLink = document.querySelectorAll('.list-item-content__button'); 
      let pcAddLinkItem = document.querySelectorAll('.list-item'); 
      let i;

      for (i=0; i<pcLink.length; i++) {
          let pcLinkAttr = pcLink[i].getAttribute("href");
          if (pcLink[i].textContent !== "") {
             pcAddLinkItem[i].innerHTML = "<a href=" + pcLinkAttr + ">" + pcAddLinkItem[i].innerHTML + "</a>"; 
          }
      }
    }
  }());

</script>

Step 3

Note the code is designed to work with 'Auto Layout' sections when set in the “Simple List”.

List Item


All work in this guide is provided ?“AS IS”. Other than as provided in this agreement, this guide makes no other warranties, express or implied, and hereby disclaims all implied warranties, including any warranty of fitness for a particular purpose.

If you require professional advice, we recommend that you purchase the services of a developer.

Primitus Consultancy

We work with small and medium-sized businesses to help create a professional online presence. We provide a one shop full-service design studio in London, United Kingdom. 

https://primitusconsultancy.co.uk
Previous
Previous

How to customise the style of the product quick view lightbox

Next
Next

How to create sliding underline on hover for button blocks