You can send your questions to my email to get faster answer in 24 hours (free).
Buy me a coffee

Click Text – Show Spotify

Demo: https://tuanphan-demo01.squarespace.com/click-text-show-spotify?noredirect

Pass: abc

Suppose you have 2 Texts.
You want: when users click on each Text >> Show Spotify.

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

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

  • #spotify01
  • #spotify02

click-text-show-spotify-01-min (1)

click-text-show-spotify-02-min (1)

and 2 Spotify Playlists below.

click-text-show-spotify-07-min

#2. Install Squarespace ID Finder to find the ID of Text and Spotify.

In my example, we will have:

  • Left Text Block: #block-yui_3_17_2_1_1710486514450_34580
  • Spotify 01: #block-yui_3_17_2_1_1710486514450_23026
  • Spotify 02: #block-yui_3_17_2_1_1710486514450_25070

click-text-show-spotify-08-min

#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(){
  // Spotify 01 
  $("#block-yui_3_17_2_1_1710486514450_23026").closest('.fe-block').addClass('spotify01');
  // Spotify 02 
$("#block-yui_3_17_2_1_1710486514450_25070").closest('.fe-block').addClass('spotify02');
  
  // Spotify 01
  $('a[href="#spotify01"]').click(function(){
    $(".spotify01").addClass("show");
    $('.fe-block:not(.spotify01)').removeClass('show');
    }
  );
// Spotify 02  
 $('a[href="#spotify02"]').click(function(){
   $(".spotify02").addClass("show");
    $('.fe-block:not(.spotify02)').removeClass('show');
    }
  );
});
</script>
<style>
.spotify01 .code-block, .spotify02 .code-block {
    display: none;
}
  .show .code-block {
      display: block !important;
  }
  .show {
      z-index: 999999 !important;
  }
</style>

click-text-show-spotify-09-min

#4. Explain code

click-text-show-spotify-10-min

Ask me a question, free

If your site is private or in trial, just setup password and share url. See how to: https://beaverhero.com/squarespace-how-to/
Please check your email carefully. Recently I got a lot of questions with wrong emails.

If you haven't heard from me within 24 hours please check your junk/spam folder