Demo: https://tuanphan-demo01.squarespace.com/hover-text-show-image-on-right?noredirect
Pass: abc
Suppose you have 5 texts: Apple, Microsoft, Facebook, Instagram, and Google.
You want: when users hover on each text > show an image on the right side, something like this.
#1. First, add a Text Block with 5 Paragraph, then add these URLs
- Apple – #apple
- Microsoft – #microsoft
- Facebook – #facebook
- Instagram – #instagram
- Google – #google
and make sure “Open Link in new tab” is DISABLED.
#2. Add 5 Image Blocks on the right side (You can drag them to make them overlap together then, or keep the current position if you want).
#3. Install Squarespace ID Finder tool (Free)
Then, you can find the ID of 5 Image Blocks and Text Block with the tool. In this example, we will have
- Section ID: section[data-section-id=”65ddb0e3774fbc5683717e39″]
- Text Block: #block-yui_3_17_2_1_1709027479615_23578
- Apple Image: #block-yui_3_17_2_1_1709027479615_25260
- Microsoft: #block-yui_3_17_2_1_1709027479615_25837
- Facebook: #block-yui_3_17_2_1_1709027479615_26404
- Instagram: #block-yui_3_17_2_1_1709027479615_26980
- Google: #block-yui_3_17_2_1_1709027479615_27455
#4. 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(){ // Apple $("#block-yui_3_17_2_1_1709027479615_25260").closest('.fe-block').addClass('apple show'); $('a[href="#apple"]').addClass('active-link'); // Microsoft $("#block-yui_3_17_2_1_1709027479615_25837").closest('.fe-block').addClass('microsoft'); // Facebook $("#block-yui_3_17_2_1_1709027479615_26404").closest('.fe-block').addClass('facebook'); // Instagram $("#block-yui_3_17_2_1_1709027479615_26980").closest('.fe-block').addClass('instagram'); // Google $("#block-yui_3_17_2_1_1709027479615_27455").closest('.fe-block').addClass('google'); // Apple $('a[href="#apple"]').hover(function(){ $(".apple").addClass("show"); $('.fe-block:not(.apple)').removeClass('show'); $(this).addClass('active-link'); $('a:not([href="#apple"])').removeClass('active-link'); } ); // Microsoft $('a[href="#microsoft"]').hover(function(){ $(".microsoft").addClass("show"); $('.fe-block:not(.microsoft)').removeClass('show'); $(this).addClass('active-link'); $('a:not([href="#microsoft"])').removeClass('active-link'); } ); // Facebook $('a[href="#facebook"]').hover(function(){ $(".facebook").addClass("show"); $('.fe-block:not(.facebook)').removeClass('show'); $(this).addClass('active-link'); $('a:not([href="#facebook"])').removeClass('active-link'); } ); // Instagram $('a[href="#instagram"]').hover(function(){ $(".instagram").addClass("show"); $('.fe-block:not(.instagram)').removeClass('show'); $(this).addClass('active-link'); $('a:not([href="#instagram"])').removeClass('active-link'); } ); // Google $('a[href="#google"]').hover(function(){ $(".google").addClass("show"); $('.fe-block:not(.google)').removeClass('show'); $(this).addClass('active-link'); $('a:not([href="#google"])').removeClass('active-link'); } ); }); </script> <style> .apple .image-block, .microsoft .image-block, .facebook .image-block, .instagram .image-block, .google .image-block { display: none; } .show .image-block { display: block !important; } .show { z-index: 999999 !important; } .active-link * { color: #f1f !important; } </style>
#5. Explain