Buy me a coffee

Click Text – Show Product Block

Demo: https://tuanphan4-test.squarespace.com/click-text-show-product-block?noredirect

Pass: abc

#1. First, you add a Text Block on the left, with some text/url.

Make sure the option “Open link in new tab” is disabled

  • Product 01 – #product01
  • Product 02 – #product02
  • Product 03 – #product03

Click Text Show Product Block 01 Min

Hover Text Show Product Block 02 Min

Click Text Show Product Block 03 Min

and 3 Product Blocks on the right.

Click Text Show Product Block 04 Min

#2. Install Squarespace ID Finder and find the ID of all blocks

In my example, we will have:

  • Left text block: #block-yui_3_17_2_1_1710486514450_13266
  • Product 01: #block-yui_3_17_2_1_1710486514450_14818
  • Product 02: #block-yui_3_17_2_1_1710486514450_15817
  • Product 03: #block-yui_3_17_2_1_1710486514450_20936

Click Text Show Product Block 05 Min

#3. Use this code to Code Injection – Footer (or Page Header Code Injection)

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
  // Product 01
  $('#block-yui_3_17_2_1_1710486514450_13266 a[href="#product01"]').click(function(){
    $("#block-yui_3_17_2_1_1710486514450_14818").addClass("show");
$('div:not(#block-yui_3_17_2_1_1710486514450_14818)').removeClass('show');
    }
  );
// Product 02
 $('#block-yui_3_17_2_1_1710486514450_13266 a[href="#product02"]').click(function(){
    $("#block-yui_3_17_2_1_1710486514450_15817").addClass("show");
$('div:not(#block-yui_3_17_2_1_1710486514450_15817)').removeClass('show');
    }
  );
  // Product 03 
   $('#block-yui_3_17_2_1_1710486514450_13266 a[href="#product03"]').click(function(){
    $("#block-yui_3_17_2_1_1710486514450_20936").addClass("show");
$('div:not(#block-yui_3_17_2_1_1710486514450_20936)').removeClass('show');
    }
  );
});
</script>
<style>
#block-yui_3_17_2_1_1710486514450_14818, #block-yui_3_17_2_1_1710486514450_15817, #block-yui_3_17_2_1_1710486514450_20936 {
  opacity: 0;
  transition: all 0.1s ease;
  }
  .show {
  opacity: 1 !important;
     transition: all 0.1s ease;
  }
</style>

Click Text Show Product Block 06 Min

#4. Explain code

Click Text Show Product Block 07 Min