Demo: https://tuanphan-demo01.squarespace.com/hover-text-show-accordion?noredirect
Password: abc
Suppose you have 2 texts.
You want: when users hover on each Text >> Show Accordion.
#1. First, add a Text Block with 2 different texts, then add these URLs:
- #accordion01
- #accordion02
Make sure “Open Link in new tab” is DISABLED.
and 2 Accordion Blocks below it.
#2. Use this free tool to find the ID of the Text and Accordion
In my example, we will have:
- Text Block: #block-yui_3_17_2_1_1710551091735_14009
- Accordion 01: #block-yui_3_17_2_1_1710551091735_10143
- Accordion 02: #block-yui_3_17_2_1_1710551091735_7772
#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(){ // Accordion 01 $("#block-yui_3_17_2_1_1710551091735_10143").closest('.fe-block').addClass('accordion01'); // Accordion 02 $("#block-yui_3_17_2_1_1710551091735_7772").closest('.fe-block').addClass('accordion02'); // Accordion 01 $('a[href="#accordion01"]').hover(function(){ $(".accordion01").addClass("show"); $('.fe-block:not(.accordion01)').removeClass('show'); } ); // Accordion 02 $('a[href="#accordion02"]').hover(function(){ $(".accordion02").addClass("show"); $('.fe-block:not(.accordion02)').removeClass('show'); } ); }); </script> <style> .accordion01 .accordion-block, .accordion02 .accordion-block { display: none; } .show .accordion-block { display: block !important; } .show { z-index: 999999 !important; } </style>
#4. Explain code