Demo: https://tuanphan-demo01.squarespace.com/hover-image-show-text?noredirect
Password: abc
Suppose you have 4 images. When users hover on each image, you want: the text on the right (or anywhere) will appear.
#1. First, add 4 images on the left – and 4 texts on the right
#2. Install Squarespace ID Finder to find the ID of Image and Text Blocks
In my example, we will have:
- Apple image: #block-yui_3_17_2_1_1710294018691_31466
- Google image: #block-yui_3_17_2_1_1710294018691_32130
- Microsoft image: #block-yui_3_17_2_1_1710294018691_32792
- Instagram image: #block-yui_3_17_2_1_1710294018691_33566
- Apple text: #block-yui_3_17_2_1_1710294018691_37035
- Google text: #block-yui_3_17_2_1_1710294018691_38473
- Microsoft image: #block-yui_3_17_2_1_1710294018691_39737
- Instagram text: #block-yui_3_17_2_1_1710294018691_41344
#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(){ // Apple $('#block-yui_3_17_2_1_1710294018691_31466').hover(function(){ $("#block-yui_3_17_2_1_1710294018691_37035").addClass("show"); }, function(){ $('#block-yui_3_17_2_1_1710294018691_37035').removeClass("show"); } ); // Google $('#block-yui_3_17_2_1_1710294018691_32130').hover(function(){ $("#block-yui_3_17_2_1_1710294018691_38473").addClass("show"); }, function(){ $('#block-yui_3_17_2_1_1710294018691_38473').removeClass("show"); } ); // Microsoft $('#block-yui_3_17_2_1_1710294018691_32792').hover(function(){ $("#block-yui_3_17_2_1_1710294018691_39737").addClass("show"); }, function(){ $('#block-yui_3_17_2_1_1710294018691_39737').removeClass("show"); } ); // Instagram $('#block-yui_3_17_2_1_1710294018691_33566').hover(function(){ $("#block-yui_3_17_2_1_1710294018691_41344").addClass("show"); }, function(){ $('#block-yui_3_17_2_1_1710294018691_41344').removeClass("show"); } ); }); </script> <style> #block-yui_3_17_2_1_1710294018691_37035, #block-yui_3_17_2_1_1710294018691_38473, #block-yui_3_17_2_1_1710294018691_39737, #block-yui_3_17_2_1_1710294018691_41344 { opacity: 0; transition: all 0.1s ease; } .show { opacity: 1 !important; transition: all 0.1s ease; } </style>
#4. Explain code