Demo: https://tuanphan-demo01.squarespace.com/click-button-show-summary-block?noredirect
Password: abc
Description: Click on each button > Show the corresponding Summary Block.
#1. First, you add 2 Button Blocks with some text/url.
Make sure the option “Open link in new tab” is disabled
- #summary01
- #summary02
and 2 Summary Blocks below.
#2. Install Squarespace ID Finder to find the ID of the Summary Block.
In my example, we will have:
- Left Summary Block: #block-dcc154438c3fdc691546
- Right Summary Block: #block-b4165d59fefd2fcb2980
#3. Use 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(){ // Summary 01 $("#block-dcc154438c3fdc691546").closest('.fe-block').addClass('summary01 show'); $('a[href="#summary01"]').addClass('active-button'); // Summary 02 $("#block-b4165d59fefd2fcb2980").closest('.fe-block').addClass('summary02'); // Summary 01 $('a[href="#summary01"]').click(function(){ $(".summary01").addClass("show"); $('.fe-block:not(.summary01)').removeClass('show'); $(this).addClass('active-button'); $('a:not([href="#summary01"])').removeClass('active-button'); } ); // Summary 02 $('a[href="#summary02"]').click(function(){ $(".summary02").addClass("show"); $('.fe-block:not(.summary02)').removeClass('show'); $(this).addClass('active-button'); $('a:not([href="#summary02"])').removeClass('active-button') } ); }); </script> <style> .summary01 .summary-v2-block, .summary02 .summary-v2-block { display: none; } .show .summary-v2-block { display: block !important; } .show { z-index: 999999 !important; } .active-button { background-color: green !important; } </style>
#4. Explain code