Demo: https://tuanphan-demo01.squarespace.com/hover-button-show-donation-block-v2?noredirect
Password: abc
Suppose you have 2 Button Blocks and 2 Donation Blocks
When hovering over each button, Donation Blocks will appear below it
You can follow these steps:
#1. First, add 2 Button Blocks and 2 Donation Blocks.
#2. Edit 2 Button Blocks, and use these URLs:
- #donate01
- #donate02
and make sure the option “Open Link in New Tab” is disabled.
#3. Install Squarespace ID Finder to find the ID of Buttons and Spotify
In my example, we will have:
- Button 01: #block-yui_3_17_2_1_1711157606982_22841
- Button 02: #block-yui_3_17_2_1_1711157606982_19548
- Donate to A: #block-yui_3_17_2_1_1711157606982_9898
- Donate to B: #block-yui_3_17_2_1_1711157606982_10549
#4. 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(){ // Donate 01 $("#block-yui_3_17_2_1_1711157606982_9898").closest('.fe-block').addClass('donate01 show'); // Donate 02 $("#block-yui_3_17_2_1_1711157606982_10549").closest('.fe-block').addClass('donate02'); // Donate 01 $('a[href="#donate01"]').hover(function(){ $(".donate01").addClass("show"); $('.fe-block:not(.donate01)').removeClass('show'); } ); // Donate 02 $('a[href="#donate02"]').hover(function(){ $(".donate02").addClass("show"); $('.fe-block:not(.donate02)').removeClass('show'); } ); }); </script> <style> .donate01 .donation-block, .donate02 .donation-block { display: none; } .show .donation-block { display: block !important; } .show { z-index: 999999 !important; } </style>
#5. Explain code