Jump to content

[Share] Click Text - Show Gallery

Recommended Posts

Suppose you have 2 Texts.

You want: when users click on each Text > Show corresponding Gallery Block.

You can follow these steps

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

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

  • #team01
  • #team02

image.png.2b81f819c89e499ae5dadca9612c3e67.png

image.png.3e9d3a10960c9a783f1ef8745985ea40.png

and 2 Gallery Blocks below (or on right of Text)

image.png.1ea88cfc6d4b5aefe73adccb5ef2a8e4.png

#2. Use this tool to find ID of Blocks

In my example, we will have:

  • Left Gallery: #block-yui_3_17_2_1_1714699207155_19750
  • Right Gallery: #block-yui_3_17_2_1_1714699207155_20357

image.png.d0188459b191840a1de3ca3226fbfbe0.png

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

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
  // Team 01
  $("#block-yui_3_17_2_1_1714699207155_19750").closest('.fe-block').addClass('team01 show');
  // Team 02
$("#block-yui_3_17_2_1_1714699207155_20357").closest('.fe-block').addClass('team02');
  
  // Team 01
  $('a[href="#team01"]').click(function(){
    $(".team01").addClass("show");
    $('.fe-block:not(.team01)').removeClass('show');
    }
  );
// Team 02
 $('a[href="#team02"]').click(function(){
   $(".team02").addClass("show");
    $('.fe-block:not(.team02)').removeClass('show');
    }
  );
});
</script>
<style>
.team01 .gallery-block, .team02 .gallery-block {
    display: none;
}
  .show .gallery-block {
      display: block !important;
  }
  .show {
      z-index: 999999 !important;
  }
</style>

image.png.686ce78426649efaf0ed1760b6739ad7.png

#4. Explain code a bit

image.png.f475d36393f6fc1a9accd4abda7511a7.png

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • Replies 0
  • Views 276
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted Images

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.